emilk / drop-merge-sort

A novel adaptive sorting algorithm
MIT License
172 stars 10 forks source link

Heads-up: UB due to misuse of mem::uninitialized will soon lead to panic #2

Closed RalfJung closed 3 years ago

RalfJung commented 4 years ago

Here, this crate causes UB by "Producing an invalid value". Concretely, it creates an arbitrary T with mem::uninitialized(). In the near future the call to mem::uninitialized() will panic to avoid UB, and our crater run determined that this crate will be affected.

mem::uninitialized() is deprecated since Rust 1.39. The intended replacement is MaybeUninit, which tracks the possibility of uninitialized values at the type level to make sure the compiler does not make any false assumptions.

calixteman commented 3 years ago

@RalfJung, any chance to have a fix here ?

RalfJung commented 3 years ago

I'm not familiar with this library I am afraid. I am working on rustc and the library just showed up when we did our regression testing for this change. Cc https://github.com/rust-lang/rust/issues/66151

The library does not seem maintained any more; I am not sure what would be good replacements.

emilk commented 3 years ago

@ilaril made a beautiful fix, and I have released a 1.0.1