Skip to content

Conversation

saethlin
Copy link
Contributor

To deference a pointer, it must be correctly aligned for T. Since there's no alignment check at runtime or enforcement by the type system, this code must use read_unaligned to read the integer's bytes out of the slice. Code like this tends to work fine on x86 because it generally supports unaligned memory access, but may fault on other architectures.

This problem can be demonstrated by running cargo miri test before this PR.

@dermesser dermesser merged commit 8f590d5 into dermesser:master Feb 22, 2022
@dermesser
Copy link
Owner

Thank you for the precaution! On Linux x86_64, it is easy to be myopic to these things

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants