gnzlbg / jemallocator

Rust allocator using jemalloc as a backend
Apache License 2.0
401 stars 106 forks source link

jemalloc 5.1 causes memory corruption with the `max_background_threads` option. #174

Open awused opened 2 years ago

awused commented 2 years ago

I'm reporting this even though the crate is unmaintained because it ended up wasting a lot of my own time. 5.2 and 5.2.1 have some fixes for max_background_threads specifically and memory corruption in general. Switching to https://crates.io/crates/tikv-jemallocator appears to have resolved them since it has updated to 5.2.1.

Using this crate and _RJEM_MALLOC_CONF=abort_conf:true,background_thread:true,max_background_threads:1 I was able to corrupt memory in rayon: this line panicked, but only once by luck and I've not been able to reproduce it. More commonly my application just crashed with various errors.

The most common crash is tpp.c:84: __pthread_tpp_change_priority: Assertion `new_prio == -1 || (new_prio >= fifo_min_prio && new_prio <= fifo_max_prio)' failed. and the second most common is a more generic illegal hardware instruction that I haven't bothered to dig deeply into.