-
Notifications
You must be signed in to change notification settings - Fork 50
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
fix: alignment in unsafe rust #1486
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
80b1789
to
92d0bba
Compare
Commit: 92d0bba |
} else { | ||
panic!("limbs must be at most 48"); | ||
} | ||
|
||
let block_size = proc_macro::Literal::usize_unsuffixed(block_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh wow good to know this exists
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait, I copied this from code you wrote!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I thought I used some hacks for this, but maybe this was the hack...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hope it's all and hope no major performance issues are introduced
Rust treats
[u8; LEN]
as having alignment of1
, so if you unsafely transmute or convert a slice to[T; LEN]
which expects alignment ofalign_of<T>()
, then this may result in misaligned load/store instructions, often during operations like memcpy. OpenVM RV32 does not support misaligned access (see #1474), so we make sure all our use of unsafe Rust has proper alignment.