-- Override standard malloc (MI_OVERRIDE=ON)
-- Set full secure build (MI_SECURE=ON)
-- Set debug level to full internal invariant checking (MI_DEBUG_FULL=ON)
-- Enable abort() calls on memory allocation failure (MI_XMALLOC=ON)
-- Enable printing of error and warning messages by default (MI_SHOW_ERRORS=ON)
-- Use the C++ compiler to compile (MI_USE_CXX=ON)
--
-- Library base name: mimalloc-secure-debug
-- Version : 2.1
-- Build type : debug
-- C++ Compiler : /usr/bin/clang++
-- Compiler flags : -Wno-deprecated;-Wall;-Wextra;-Wno-unknown-pragmas;-fvisibility=hidden;-Wpedantic;-Wno-static-in-inline;-ftls-model=initial-exec;-fno-builtin-malloc
-- Compiler defines : MI_SECURE=4;MI_DEBUG=3;MI_XMALLOC=1;MI_SHOW_ERRORS=1
-- Link libraries : /usr/lib/x86_64-linux-gnu/libpthread.so;/usr/lib/x86_64-linux-gnu/librt.so
-- Build targets : shared
in the following page, it seems that
186 mi_thread_free_t tfree = mi_atomic_load_relaxed(&page->xthread_free);
187 do {
188 head = mi_tf_block(tfree);
results in a nullptr head
190 } while (!mi_atomic_cas_weak_acq_rel(&page->xthread_free, &tfree, tfreex));
191
192 // return if the list is empty
-> 193 if (head == NULL) return;
which prevents it from being added to the page->local_free list for freeing
Process 1554835 stopped
* thread #1, name = 'stack_exe', stop reason = step in
frame #0: 0x00007ffff7f6d2b9 libmimalloc-secure-debug.so.2`_mi_page_free_collect(page=0x0000039f2a000168, force=true) at page.c:227:7
224 }
225
226 // and the local free list
-> 227 if (page->local_free != NULL) {
228 if mi_likely(page->free == NULL) {
229 // usual case
230 page->free = page->local_free;
(lldb) s
Process 1554835 stopped
* thread #1, name = 'stack_exe', stop reason = step in
frame #0: 0x00007ffff7f6d399 libmimalloc-secure-debug.so.2`_mi_page_free_collect(page=0x0000039f2a000168, force=true) at page.c:248:3
245 }
246 }
247
-> 248 mi_assert_internal(!force || page->local_free == NULL);
249 }
250
251
in the following page, it seems that
results in a
nullptr
headwhich prevents it from being added to the
page->local_free
list for freeing