Skip to content

Transforming &[u8; 16] to [u64; 2] using transmute_copy causes Bus errors on aarch64 #55044

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

Closed
newpavlov opened this issue Oct 13, 2018 · 3 comments · Fixed by #55052
Closed

Comments

@newpavlov
Copy link
Contributor

newpavlov commented Oct 13, 2018

See this issue: RustCrypto/stream-ciphers#5

The line in question is here. Does it contain UB or is it a miscompilation? If it's the former, then I think transmute_copy documentation should be updated accordingly.

@matthewjasper
Copy link
Contributor

It's definitely UB somewhere: try running this with MIRI https://play.rust-lang.org/?version=stable&mode=debug&edition=2015&gist=794f6a68cf5009fe2c9c8c1277fd42f0.

@newpavlov
Copy link
Contributor Author

newpavlov commented Oct 13, 2018

Looks like replacing transmute_copy with read_unaligned solves the problem. But is it intended for transmute_copy to use aligned load? Currently it uses ptr::read, shouldn't it be replaced with ptr::read_unaligned?

@newpavlov
Copy link
Contributor Author

newpavlov added a commit to newpavlov/rust that referenced this issue Oct 13, 2018
Closes: rust-lang#55044

This change could result in performance regression on non-x86 platforms. Alternative would be to update `transmute_copy` with alignment requirements.
bors added a commit that referenced this issue Nov 13, 2018
Use read_unaligned instead of read in transmute_copy

Closes: #55044

This change could result in performance regression on non-x86 platforms. (but it also can fix some of UB which lurks in existing programs) An alternative would be to update `transmute_copy` documentation with alignment requirements.
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 a pull request may close this issue.

2 participants