hawkw / sharded-slab

a lock-free concurrent slab (experimental)
MIT License
269 stars 17 forks source link

sharded-slab v0.1.5 tests fail to compile on 32-bit x86 #82

Closed decathorpe closed 1 year ago

decathorpe commented 1 year ago

I'm maintaining the packages for this crate for Fedora Linux, and it appears that the update to v0.1.5 introduces issues that prevent its tests from compiling on 32-bit x86 (i.e. i686-unknown-linux-gnu), in what looks like compile-time evaluation issue:

error[E0080]: evaluation of `<page::slot::Generation<tests::custom_config::CustomConfig> as Pack<tests::custom_config::CustomConfig>>::LEN` failed
  --> src/page/slot.rs:59:24
   |
59 |     const LEN: usize = (cfg::WIDTH - C::RESERVED_BITS) - Self::SHIFT;
   |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `8_usize - 30_usize`, which would overflow
note: erroneous constant used
    --> src/lib.rs:1030:27
     |
1030 |         let shift = 1 << (Self::LEN - 1);
     |                           ^^^^^^^^^
note: erroneous constant used
    --> src/lib.rs:1043:25
     |
1043 |     const MASK: usize = Self::BITS << Self::SHIFT;
     |                         ^^^^^^^^^^
note: the above error was encountered while instantiating `fn Slab::<u64, tests::custom_config::CustomConfig>::insert::{closure#0}`
 --> /builddir/build/BUILD/rustc-1.72.0-src/library/core/src/ops/function.rs:305:13
note: erroneous constant used
   --> src/page/slot.rs:688:60
    |
688 |     const LEN: usize = cfg::WIDTH - (Lifecycle::<C>::LEN + Generation::<C>::LEN);
    |                                                            ^^^^^^^^^^^^^^^^^^^^
note: erroneous constant used
    --> src/lib.rs:1038:46
     |
1038 |     const SHIFT: usize = Self::Prev::SHIFT + Self::Prev::LEN;
     |                                              ^^^^^^^^^^^^^^^
note: erroneous constant used
    --> src/lib.rs:1043:39
     |
1043 |     const MASK: usize = Self::BITS << Self::SHIFT;
     |                                       ^^^^^^^^^^^
note: erroneous constant used
   --> src/page/slot.rs:760:24
    |
760 |     const LEN: usize = Generation::<C>::LEN;
    |                        ^^^^^^^^^^^^^^^^^^^^
note: erroneous constant used
  --> src/cfg.rs:43:30
   |
43 |     const USED_BITS: usize = Generation::<Self>::LEN + Generation::<Self>::SHIFT;
   |                              ^^^^^^^^^^^^^^^^^^^^^^^
note: erroneous constant used
   --> src/page/slot.rs:705:35
    |
705 |     pub(crate) const MAX: usize = Self::BITS - 1;
    |                                   ^^^^^^^^^^
note: erroneous constant used
  --> src/cfg.rs:90:13
   |
90 |             RefCount::<Self>::MAX,
   |             ^^^^^^^^^^^^^^^^^^^^^
note: erroneous constant used
   --> src/cfg.rs:160:34
    |
160 |             .field("used_bits", &C::USED_BITS)
    |                                  ^^^^^^^^^^^^
note: erroneous constant used
   --> src/cfg.rs:163:50
    |
163 |             .field("max_concurrent_references", &RefCount::<C>::MAX)
    |                                                  ^^^^^^^^^^^^^^^^^^
note: erroneous constant used
   --> src/page/slot.rs:710:61
    |
710 |             test_println!("-> get: {}; MAX={}", self.value, RefCount::<C>::MAX);
    |                                                             ^^^^^^^^^^^^^^^^^^
For more information about this error, try `rustc --explain E0080`.
error: could not compile `sharded-slab` (lib test) due to previous error
hawkw commented 1 year ago

thanks for the report, i'll look into this!

hawkw commented 1 year ago

I've yanked v0.1.5 from crates.io to avoid breaking anyone else's 32-bit builds. We'll release a new version once this is fixed.

decathorpe commented 1 year ago

Thank you for looking into it!

loyd commented 1 year ago

Exactly the version I needed =)

hawkw commented 1 year ago

@loyd sorry, I'm working on getting a fix for this so we can release a v0.1.6 that will contain your changes and compile for 32-bit platforms! :)