rust-lang / hashbrown

Rust port of Google's SwissTable hash map
https://rust-lang.github.io/hashbrown
Apache License 2.0
2.46k stars 288 forks source link

0.15 not compatible with 1.63 despite `rust-version` hint #574

Closed davidhewitt closed 1 month ago

davidhewitt commented 1 month ago

Related to #571 / #572

On PyO3's MSRV CI runs (also 1.63, which hashbrown has in its Cargo.toml) we are getting runtime panics from atomic orderings incompatible with 1.63.

It looks like the root cause is the new foldhash dependency, which does not have any rust-version in its Cargo.toml. The code in question has existed since the first release of foldhash, so I can only conclude that crate does not support 1.63 at all, and thus hashbrown can't either.

https://github.com/PyO3/pyo3/actions/runs/11271186265/job/31344727179#step:18:957

thread 'conversions::hashbrown::tests::test_extract_hashbrown_hashset' panicked at 'a failure ordering can't be stronger than a success ordering', /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/sync/atomic.rs:2700:18
stack backtrace:
   0: rust_begin_unwind
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/panicking.rs:142:14
   2: core::sync::atomic::atomic_compare_exchange_weak
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/sync/atomic.rs:2700:18
   3: core::sync::atomic::AtomicU8::compare_exchange_weak
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/sync/atomic.rs:1937:21
   4: foldhash::seed::global::GlobalSeed::init_slow
             at /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/foldhash-0.1.3/src/seed.rs:277:23
   5: foldhash::seed::global::GlobalSeed::new
             at /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/foldhash-0.1.3/src/seed.rs:263:17
   6: <foldhash::seed::fast::RandomState as core::default::Default>::default
             at /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/foldhash-0.1.3/src/seed.rs:72:30
   7: <hashbrown::set::HashSet<T,S,A> as core::iter::traits::collect::FromIterator<T>>::from_iter
             at /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/hashbrown-0.15.0/src/set.rs:1271:44
cuviper commented 1 month ago

That ordering restriction was removed by https://github.com/rust-lang/rust/pull/98383/ in Rust 1.64.

So yes, the default hasher from foldhash is going to be limited by that. However, hashbrown itself will still work on 1.63 with default-features = "false", if you choose a different hasher for your use.

davidhewitt commented 1 month ago

Ah, makes sense. I hadn't considered the feature combination 👍

Thanks for clarifying that. I think let's close this given the MSRV testing seems to be incoming in #572