From dd53da2996119c6caef5c93a8401e7a6d89d3f71 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Fri, 4 Sep 2026 23:13:20 +0800 Subject: [PATCH] fix(sys): mimalloc3 v3.5.1 + fix for the process-init thread's thread-done hook mimalloc v3.5.0 (shipped by #92) never associates the process-init thread's theap with the pthread thread-done key. When the first thread that touches the allocator exits (a Node.js worker that loads the addon first), `_mi_thread_done` never runs for it, its theap stays registered with its thread id, and the next thread that reuses that pthread TCB aborts in debug builds: mimalloc: assertion failed: at "src/init.c":327, _mi_thread_init_with_heap assertion: "theap==NULL" Release builds skip the assert but leak the dead thread's theap and pages. Upstream culprit: microsoft/mimalloc@5d9cb381; reported with the fix as microsoft/mimalloc#1393. Point the `mimalloc3` submodule at the napi-rs/mimalloc fork branch `fix/first-thread-done` = upstream v3.5.1 + the 11-line src/init.c fix (same approach as #71), until upstream ships it. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01T34fMrYCf2V13Mg8BKmnda --- .gitmodules | 4 ++-- libmimalloc-sys/c_src/mimalloc3 | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitmodules b/.gitmodules index c1a25fb..c1b5096 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,5 +3,5 @@ url = https://github.com/microsoft/mimalloc.git [submodule "libmimalloc-sys/c_src/mimalloc3"] path = libmimalloc-sys/c_src/mimalloc3 - url = https://github.com/microsoft/mimalloc.git - branch = dev3 + url = https://github.com/napi-rs/mimalloc.git + branch = fix/first-thread-done diff --git a/libmimalloc-sys/c_src/mimalloc3 b/libmimalloc-sys/c_src/mimalloc3 index 18b0867..1e5d14c 160000 --- a/libmimalloc-sys/c_src/mimalloc3 +++ b/libmimalloc-sys/c_src/mimalloc3 @@ -1 +1 @@ -Subproject commit 18b08671c9302247bfb682286e6bf3cc1773f801 +Subproject commit 1e5d14ca11b27fb352820405d2ed422c7b56b468