-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Closed
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Description
Cargo's test_cratesio_hash fails with rust 1.56.0 on Debian systems that are not little-endian 64-bit. Digging deeper, I found the problem has existed in rustc since 1.45, using only the following test program that uses the rust standard library only, no cargo code at all:
use std::hash::{Hash, Hasher, SipHasher};
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum SourceKind {
Git(GitReference),
Path,
Registry,
LocalRegistry,
Directory,
}
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum GitReference {
Tag(String),
Branch(String),
Rev(String),
DefaultBranch,
}
pub fn hash_pair(r: SourceKind, a: &str) -> u64 {
let mut hasher = SipHasher::new();
r.hash(&mut hasher);
a.hash(&mut hasher);
hasher.finish()
}
fn main() {
assert_eq!(
hash_pair(SourceKind::Registry, "https://github.com/rust-lang/crates.io-index"),
//0x1ecc6299db9ec823
//0x 1e cc 62 99 db 9e c8 23
0x23c89edb9962cc1e // little-endian
);
}The program fails with rust-1.45.0-i686-unknown-linux-gnu and later, and passes with rust-1.44.0-i686-unknown-linux-gnu and earlier.
The issue causes cargo's test_cratesio_hash to fail on Debian, but the underlying problem is not Debian-specific. Failing values:
Little-endian 32-bit 0x1285ae84e5963aae
- https://buildd.debian.org/status/fetch.php?pkg=cargo&arch=i386&ver=0.57.0-1&stamp=1635039377&raw=0
- https://buildd.debian.org/status/fetch.php?pkg=cargo&arch=armel&ver=0.57.0-1&stamp=1635040503&raw=0
- https://buildd.debian.org/status/fetch.php?pkg=cargo&arch=x32&ver=0.57.0-1&stamp=1635040107&raw=0
Big-endian 64-bit 0xeae4ba8cbf2ce1c7
- https://buildd.debian.org/status/fetch.php?pkg=cargo&arch=s390x&ver=0.57.0-1&stamp=1635039272&raw=0
- https://buildd.debian.org/status/fetch.php?pkg=cargo&arch=ppc64&ver=0.57.0-1&stamp=1635039805&raw=0
- https://buildd.debian.org/status/fetch.php?pkg=cargo&arch=sparc64&ver=0.57.0-1&stamp=1635040157&raw=0
Big-endian 32-bit 0xb420f105fcaca6de
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.