-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Don't byteswap Fingerprints when encoding #42335
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @eddyb (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
src/librustc/ich/fingerprint.rs
Outdated
let _0 = u64::from_le(d.read_u64()?); | ||
let _1 = u64::from_le(d.read_u64()?); | ||
let _0 = d.read_u64()?; | ||
let _1 = d.read_u64()?; | ||
Ok(Fingerprint(_0, _1)) |
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.
Can you move it to use #[derive]
? Looks like it's what deriving would produce, now.
Thanks for the PR! I'll review it as soon as I find the time. |
This explanation doesn’t exactly make any sense to me. It seems to me like going from machine specific to low endian in encoded form to machine specific after decoding is in fact the correct way to do this. Maybe instead it is a problem with the comment just below that says:
or something like that? |
Not if So if you are doing a superfluous conversion host <-> little endian, it won't mean any problems if you serialize and deserialize on the same host, but if you serialize on a host with one byte order, and deserialize on a host with another, you will get the order mixed up.
Nope, thats a different thing. The comment is correct, we actually encode to little endian. Admittedly, the code smells bad, it shouldn't have to use unsafe, but rather something safe with (hopefully) equivalent performance. That's a different issue though. |
Thanks again, @jcowgill! Some comments:
Little- to big-endian host is analogous. So this gets an r+ from me once @eddyb's suggestion is implemented. |
Byteswapping Fingerprints when encoding is unnessesary and breaks if the Fingerprint is later decoded on a machine with different endianness to the one it was encoded on. Fix by removing the Encodable and Decodable implementations and use the ones derived from RustcEncodable and RustcDecodable. Fixes rust-lang#42239
Hi, I've now changed the fix to use |
@bors r=michaelwoerister |
📌 Commit edefcb2 has been approved by |
🎉 |
⌛ Testing commit edefcb2 with merge e776af7... |
💔 Test failed - status-travis |
@bors retry
|
@bors rollup |
…oerister Don't byteswap Fingerprints when encoding Byteswapping Fingerprints when encoding is unnessesary and breaks if the Fingerprint is later decoded on a machine with different endianness to the one it was encoded on. Fixes rust-lang#42239 This PR fixes a regression caused by rust-lang#42082. @michaelwoerister
…oerister Don't byteswap Fingerprints when encoding Byteswapping Fingerprints when encoding is unnessesary and breaks if the Fingerprint is later decoded on a machine with different endianness to the one it was encoded on. Fixes rust-lang#42239 This PR fixes a regression caused by rust-lang#42082. @michaelwoerister
…oerister Don't byteswap Fingerprints when encoding Byteswapping Fingerprints when encoding is unnessesary and breaks if the Fingerprint is later decoded on a machine with different endianness to the one it was encoded on. Fixes rust-lang#42239 This PR fixes a regression caused by rust-lang#42082. @michaelwoerister
…oerister Don't byteswap Fingerprints when encoding Byteswapping Fingerprints when encoding is unnessesary and breaks if the Fingerprint is later decoded on a machine with different endianness to the one it was encoded on. Fixes rust-lang#42239 This PR fixes a regression caused by rust-lang#42082. @michaelwoerister
Byteswapping Fingerprints when encoding is unnessesary and breaks if the Fingerprint is later decoded on a machine with different endianness to the one it was encoded on.
Fixes #42239
This PR fixes a regression caused by #42082. @michaelwoerister