On Linuxx86_64 and it seems on macOS, mimalloc v3.3.0 hangs with MI_SECURE=4 and MI_SECURE=5 on a large aligned allocation.
MRE:
#include <stdio.h>
#include "mimalloc.h"
int main(void) {
void* p = mi_malloc_aligned(1 << 20, 32);
if (p == NULL) return 1;
mi_free(p);
return 0;
}
cc -Iinclude -DMI_SECURE=4 -o repro repro.c src/static.c -lpthread ./repro
# or cc -Iinclude -DMI_SECURE=5 -o repro repro.c src/static.c -lpthread ./repro
GDB shows a self-deadlock:
- mi_arenas_try_alloc holds subproc->arena_reserve_lock
- secure path in _mi_os_get_aligned_hint calls mi_theap_get_default()
- this re-enters mi_thread_init()
- thread init allocates metadata
- allocation re-enters mi_arenas_try_alloc
- same thread blocks again on arena_reserve_lock
Relevant frames:
- mi_lock_acquire in include/mimalloc/atomic.h
- mi_arenas_try_alloc in src/arena.c
- _mi_os_get_aligned_hint in src/os.c
- _mi_thread_init_theap_default / mi_thread_init in src/init.c
On Linux
x86_64and it seems on macOS, mimalloc v3.3.0 hangs withMI_SECURE=4andMI_SECURE=5on a large aligned allocation.MRE:
cc -Iinclude -DMI_SECURE=4 -o repro repro.c src/static.c -lpthread ./repro # or cc -Iinclude -DMI_SECURE=5 -o repro repro.c src/static.c -lpthread ./reproGDB shows a self-deadlock:
Relevant frames: