-
Notifications
You must be signed in to change notification settings - Fork 0
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
VecCopy allows for misaligned access #4
Comments
Thank you! I've been meaning to get rid of the unchecked Vec casts. This is a great motivator :) |
This commit makes an initial attempt at resolving soundness issues in the API by bringing runtime alignment data to all types. Even reference types like ValueRef can use this information to be able to allocate without intantiating the concrete underlying type.
Fixed in 6972f94 and published in version 0.5. #![forbid(unsafe_code)]
use dync::{VecCopy};
#[repr(align(256))]
#[derive(Copy, Clone)]
struct LargeAlign(u8);
fn main() {
let mut x: VecCopy = VecCopy::with_type::<LargeAlign>();
x.push_as::<LargeAlign>(LargeAlign(0));
let _ref_to_element = x.get_ref_as::<LargeAlign>(0).unwrap();
} |
Hey there, I noticed that in
VecCopy
the backing storage for the Vec is au8
.dync/src/vec_copy.rs
Lines 64 to 65 in c133056
I believe this let's you trigger undefined behavior in the form of misaligned memory access through safe rust code by instantiating a
VecCopy
with a type that has different alignment requirements fromu8
. Running the following program under miri:results in:
The text was updated successfully, but these errors were encountered: