Skip to content

chore(deps): update mimalloc to v2.5.2 and mimalloc3 to v3.5.2 + init fix - #104

Merged
Brooooooklyn merged 1 commit into
mainfrom
chore/bump-mimalloc-v2.5.2-v3.5.2
Sep 14, 2026
Merged

Brooooooklyn merged 1 commit into
mainfrom
chore/bump-mimalloc-v2.5.2-v3.5.2

Conversation

@Brooooooklyn

@Brooooooklyn Brooooooklyn commented Sep 14, 2026

Copy link
Copy Markdown
Member

Background

Upstream closed microsoft/mimalloc#1393 and took the fix in a different form: microsoft/mimalloc@439dc27b, shipped in v3.5.2. That commit works on the default TLS model (verified with the #1393 repro on Linux, debug shared build: e35400bd aborts, v3.5.2 prints OK).

But it moved mi_process_setup_auto_thread_done() into mi_process_init_once() before _mi_process_is_initialized = true. With MI_TLS_RECURSE_GUARD (auto-on for MI_TLS_MODEL_LOCAL on Apple, which is what build.rs forces for v3 on macOS) _mi_theap_default() returns _mi_theap_empty at that point:

mi_process_init_once()                          [v3.5.2 src/init.c:558-564]
  ├─ mi_thread_init()                           __mi_theap_default = &mi_process_theap_main
  ├─ _mi_tls_slots_init()
  ├─ _mi_thread_locals_init()
  ├─ mi_process_setup_auto_thread_done()
  │    └─ _mi_theap_default()  ──► RECURSE_GUARD: _mi_process_is_initialized == false
  │                                ──► returns &_mi_theap_empty
  │                                ──► debug: assert fires / release: no association
  └─ _mi_process_is_initialized = true          ← too late

So on plain v3.5.2, cargo test --features v3 on macOS aborts at process init in every debug binary:

mimalloc: assertion failed: at "src/init.c":450, mi_process_setup_auto_thread_done
  assertion: "mi_theap_is_initialized(theap)"

and release builds silently skip the association, i.e. the #1393 leak is back on macOS. Reproducible with upstream alone: cmake -DCMAKE_BUILD_TYPE=Debug -DMI_TLS_MODEL=LOCAL on macOS, ./mimalloc-test-api passes on v3.5.1 and aborts on v3.5.2. Same on Linux with -DMI_TLS_RECURSE_GUARD=ON.

Changes

Verification

Upstream, macOS arm64, Debug, -DMI_TLS_MODEL=LOCAL:

tree mimalloc-test-api
v3.5.1 50/50
v3.5.2 abort at process init (134)
v3.5.2 + afa6c90d 50/50

Upstream, Linux x64 (Docker gcc:14), Debug shared, #1393 repro:

tree RECURSE_GUARD=OFF RECURSE_GUARD=ON
v3.5.2 OK abort (134)
v3.5.2 + afa6c90d OK OK

This repo, macOS arm64, every CI command: cargo test / --features secure / extended / v3 / extended,v3 all pass; libmimalloc-sys-test 258/258 (v2, secure, extended) and 251/251 (v3).

Pre-existing and untouched: upstream mimalloc-test-stress-heaps fails the refcount == 1 assert with MI_TLS_MODEL=LOCAL on macOS on v3.5.1 too; extended::tests::runtime_stable_option fails under cargo test --workspace on v2.5.1 too (not in CI).

🤖 Generated with Claude Code

https://claude.ai/code/session_016srh5svTkqfW21zGcU6ht9


Note

Medium Risk
Changes which mimalloc v3 C sources are built, affecting process/thread allocator initialization on macOS and other TLS recurse-guard configurations.

Overview
Points the mimalloc3 git submodule at the napi-rs fork branch fix/process-init-flag-before-thread-done instead of fix/first-thread-done, so v3 tracks upstream v3.5.2 plus a one-line init ordering fix: set _mi_process_is_initialized before mi_process_setup_auto_thread_done().

That avoids macOS MI_TLS_MODEL_LOCAL / recurse-guard failures where v3.5.2 alone aborts in debug or reintroduces the #1393 leak in release. No Rust or build.rs changes in this diff—only the submodule branch pin in .gitmodules.

Reviewed by Cursor Bugbot for commit 09fc0c6. Bugbot is set up for automated code reviews on this repo. Configure here.

… fix

v2: v2.5.1 -> v2.5.2 (official tag).

v3: napi-rs fork 1e5d14ca (v3.5.1 + PR microsoft/mimalloc#1393) ->
napi-rs fork afa6c90d (v3.5.2 + a one-line fix). Upstream took #1393
in a different form (439dc27b) and it is in v3.5.2, but that commit
runs `mi_process_setup_auto_thread_done` before
`_mi_process_is_initialized = true`. With `MI_TLS_RECURSE_GUARD`
(what build.rs uses on macOS for v3) `_mi_theap_default()` still
returns the empty theap there, so v3.5.2 aborts at process init in
debug builds and skips the thread-done association in release builds.
afa6c90d sets the flag first.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016srh5svTkqfW21zGcU6ht9
@cursor

cursor Bot commented Sep 14, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_3d3890ae-67c0-4f8c-9c68-c873c1ecfb6e)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 14, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-14T02:45:42.032641Z 09fc0c6 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Brooooooklyn
Brooooooklyn merged commit 2eea606 into main Sep 14, 2026
21 checks passed
@Brooooooklyn
Brooooooklyn deleted the chore/bump-mimalloc-v2.5.2-v3.5.2 branch September 14, 2026 03:37
@github-actions github-actions Bot mentioned this pull request Sep 14, 2026
Brooooooklyn pushed a commit that referenced this pull request Sep 14, 2026
## 🤖 New release

* `libmimalloc-sys2`: 0.1.62 -> 0.1.63 (✓ API compatible changes)
* `mimalloc-safe`: 0.1.66 -> 0.1.67 (✓ API compatible changes)

<details><summary><i><b>Changelog</b></i></summary><p>

## `libmimalloc-sys2`

<blockquote>

## [0.1.63] - 2026-09-14

### Chore

- *(deps)* Update mimalloc to v2.5.2 and mimalloc3 to v3.5.2 + init fix
([#104](#104))
</blockquote>

## `mimalloc-safe`

<blockquote>

## [0.1.67] - 2026-09-14

### Chore

- *(deps)* Update mimalloc to v2.5.2 and mimalloc3 to v3.5.2 + init fix
([#104](#104))
- *(deps)* Update @napi-rs/cli and emnapi, group emnapi in renovate
([#106](#106))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant