SIGFPE due to max_background_threads_write_test writing 0, and a possible patch
Hi, after investigating our CI failures, I concluded that the write test for max_background_threads wrote libc::size_t::default(), which is 0, thus causing division by zero in jemalloc function background_thread_create_locked():
static bool
background_thread_create_locked(tsd_t *tsd, unsigned arena_ind) {
assert(have_background_thread);
malloc_mutex_assert_owner(tsd_tsdn(tsd), &background_thread_lock);
/* We create at most NCPUs threads. */
size_t thread_ind = arena_ind % max_background_threads;
I believe https://github.com/tikv/jemallocator/commit/996e5b3926d42a7fa56116658b7167be71ef83bd is caused by this; indeed, with the patch below, and its disabling #[cfg] directives for mips64el removed, a thousand runs on our mips64el porter box didn't fail. I also suspect that https://github.com/tikv/jemallocator/commit/fd6f565209469531ed91b8f668c163d01d234af9 was due to the same reason, since the ptr2str function doesn't seem to have any division, but I didn't test.
I've patched our package to write 1 instead (see its description for the investigation process), but the style might not be preferable.