Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump nightly to 2023-08-25 #33048

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions accounts-db/src/append_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,7 @@ pub mod tests {
fn set_data_len_unsafe(&self, new_data_len: u64) {
// UNSAFE: cast away & (= const ref) to &mut to force to mutate append-only (=read-only) AppendVec
unsafe {
#[allow(invalid_reference_casting)]
std::ptr::write(
std::mem::transmute::<*const u64, *mut u64>(&self.meta.data_len),
new_data_len,
Expand All @@ -711,6 +712,7 @@ pub mod tests {
fn set_executable_as_byte(&self, new_executable_byte: u8) {
// UNSAFE: Force to interpret mmap-backed &bool as &u8 to write some crafted value;
unsafe {
#[allow(invalid_reference_casting)]
std::ptr::write(
std::mem::transmute::<*const bool, *mut u8>(&self.account_meta.executable),
new_executable_byte,
Expand Down
1 change: 1 addition & 0 deletions sdk/program/src/account_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ impl<'a> AccountInfo<'a> {
pub fn assign(&self, new_owner: &Pubkey) {
// Set the non-mut owner field
unsafe {
#[allow(invalid_reference_casting)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Lichtso says the compiler's being hyperbolic in calling this UB 😉

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From Rust perspective it is UB, but in LLVM the subsequent volatile write will become pretty well defined again.

std::ptr::write_volatile(
self.owner as *const Pubkey as *mut [u8; 32],
new_owner.to_bytes(),
Expand Down