That test seems to produce a lot of calls to Bump::shrink where old_size and new_size are both 1, and ptr and new_ptr are equal (so the copy is indeed overlapping).
In these cases, delta == 0 and old_size / 2 == 0, so (delta >= old_size / 2) == true.
Changing that test to delta > 0 && delta >= old_size / 2 solves this specific problem (cargo test --all-features passes), but I'm not sure if it still would allow other illegal cases through.
I'm afraid I don't understand the logic well enough to make a PR, but I hope this may be helpful in finding a fix.
The CI failure discovered in #229 is also failing on
main
(reproduced locally on M1 Macbook Pro).cargo test --features allocator_api
on nightly is sufficient to trigger it.The failing test is: https://github.com/fitzgen/bumpalo/blob/f8278d6fff870d34bda7c2d03173710b2c9d12ea/tests/all/allocator_api.rs#L163-L211
Have traced it to: https://github.com/fitzgen/bumpalo/blob/f8278d6fff870d34bda7c2d03173710b2c9d12ea/src/lib.rs#L1705-L1745
That test seems to produce a lot of calls to
Bump::shrink
whereold_size
andnew_size
are both 1, andptr
andnew_ptr
are equal (so the copy is indeed overlapping).In these cases,
delta == 0
andold_size / 2 == 0
, so(delta >= old_size / 2) == true
.Changing that test to
delta > 0 && delta >= old_size / 2
solves this specific problem (cargo test --all-features
passes), but I'm not sure if it still would allow other illegal cases through.I'm afraid I don't understand the logic well enough to make a PR, but I hope this may be helpful in finding a fix.