droundy / tinyset

Compact sets in rust
Apache License 2.0
52 stars 7 forks source link

setu32::test_alloc_failures encounters UB, will fail in Rust 1.82 #22

Open saethlin opened 2 days ago

saethlin commented 2 days ago

I am filing this issue because this project's tests failed in the crater runs for Rust 1.82: https://github.com/rust-lang/rust/issues/130579, you can reproduce this failure with cargo +beta test or cargo +nightly test.

The root cause of this is that at least with_capacity_and_bits is unsound; Layout::from_size_align_unchecked documents a precondition that the allocation size must not exceed isize::MAX: https://doc.rust-lang.org/1.81.0/std/alloc/struct.Layout.html#method.from_size_align, and the now-failing test tries to pass an allocation size of isize::MAX + 1.

droundy commented 1 day ago

Thanks for the bug report!