-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Problem
Since 1.85.0, s390x-unknown-linux-gnu fails on cargo's test_stable_hash. Here's the result on master as of commit c14c1c0:
---- core::source_id::tests::test_stable_hash stdout ----
thread 'core::source_id::tests::test_stable_hash' panicked at src/cargo/core/source_id.rs:823:9:
---- expected: src/cargo/core/source_id.rs:823:46
++++ actual: In-memory
1 - 7062945687441624357∅
1 + 2724068093996237922∅
cargo/src/cargo/core/source_id.rs
Line 823 in c14c1c0
| assert_data_eq!(gen_hash(source_id), str!["7062945687441624357"].raw()); |
The actual is byte-swapped from the expected value, even though stable-hashing is meant to be platform-agnostic.
Steps
In cargo's own repo: cargo test --lib test_stable_hash
Possible Solution(s)
No response
Notes
I found that rustc-stable-hash adds a .to_le() in its Hasher::finish, which seems suspect:
https://github.com/rust-lang/rustc-stable-hash/blob/24e9848c89917abca155c8f854118e6d00ad4a30/src/sip128.rs#L532
When cargo's test calls .to_string(), that will treat the u64 as native-endian, so it doesn't match the string that a little-endian host would produce.
Similarly, the next line in the test calls short_hash -> to_hex -> to_le_bytes, which will byte-swap it again before hex-printing it.
Version