Skip to content

chore(deps): switch mimalloc3 to upstream microsoft/mimalloc#82

Merged
shulaoda merged 1 commit into
mainfrom
06-23-chore_deps_switch_mimalloc3_to_upstream_microsoft_mimalloc
Jun 24, 2026
Merged

chore(deps): switch mimalloc3 to upstream microsoft/mimalloc#82
shulaoda merged 1 commit into
mainfrom
06-23-chore_deps_switch_mimalloc3_to_upstream_microsoft_mimalloc

Conversation

@shulaoda

Copy link
Copy Markdown
Collaborator

Background

On macOS, mimalloc v3 stores the per-thread heap pointer in a fixed TLS slot (TCB [108]/[109]) shared by every image, so a second statically-linked copy (e.g. another napi addon) adopts the first's heap and crashes. We worked around this with a vendored prim.h patch in the napi-rs/mimalloc fork. Upstream now fixes it in microsoft/mimalloc#1301 (b83dee64) by exposing cmake options, so we can drop the fork.

Changes

  • .gitmodulesmimalloc3 url napi-rs/mimallocmicrosoft/mimalloc.
  • mimalloc35853e09 (fork) → b83dee64 (official dev3); drops the vendored prim.h patch.
  • build.rs — on v3 + macOS, enable the official options:
    if env::var_os("CARGO_FEATURE_V3").is_some() && target_os == "macos" {
        cmake_config
            .define("MI_TLS_MODEL_LOCAL", "ON")     // -> MI_TLS_MODEL_THREAD_LOCAL=1
            .define("MI_TLS_RECURSE_GUARD", "ON");  // -> MI_TLS_RECURSE_GUARD=1
    }
  • mimalloc (v2) — routine bump 02a2f5dfef6b0d.

Notes

  • Scope: v3 + macOS only. Options exist only in v3; Linux already defaults to thread-local (no-op), Android/OpenBSD use pthreads, Windows uses its own TlsAlloc path. Add target_os == "ios" to cover iOS/tvOS.
  • MI_TLS_RECURSE_GUARD is belt-and-suspenders — upstream prim.h already auto-enables it on Apple; we set it explicitly for clarity.
  • No regression of the dead-main-thread fix (issue #1287 / rolldown#9722): the MI_THREADID_INVALID poison in mi_tld_free is present in b83dee64.

Verification (macOS)

  • v3 build: CMakeCache MI_TLS_MODEL_LOCAL:BOOL=ON / MI_TLS_RECURSE_GUARD:BOOL=ON; compiled with MI_TLS_MODEL_THREAD_LOCAL=1 + MI_TLS_RECURSE_GUARD=1.
  • Default (v2) build: options absent (gating works), builds clean.
  • cargo test --features v3: mimalloc-safe 6/6 pass; libmimalloc-sys-test runs.

@shulaoda shulaoda marked this pull request as ready for review June 24, 2026 03:36
@shulaoda shulaoda force-pushed the 06-23-chore_deps_switch_mimalloc3_to_upstream_microsoft_mimalloc branch from e7364eb to ddd1b1e Compare June 24, 2026 03:46
@shulaoda shulaoda merged commit f8b6ea0 into main Jun 24, 2026
19 checks passed
@shulaoda shulaoda deleted the 06-23-chore_deps_switch_mimalloc3_to_upstream_microsoft_mimalloc branch June 24, 2026 03:55
@github-actions github-actions Bot mentioned this pull request Jun 24, 2026
shulaoda pushed a commit that referenced this pull request Jun 24, 2026
## 🤖 New release

* `libmimalloc-sys2`: 0.1.59 -> 0.1.60 (✓ API compatible changes)
* `mimalloc-safe`: 0.1.63 -> 0.1.64 (✓ API compatible changes)

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

## `libmimalloc-sys2`

<blockquote>

## [0.1.60] - 2026-06-24

### Chore

- *(deps)* Switch mimalloc3 to upstream microsoft/mimalloc ([#82](#82))
</blockquote>

## `mimalloc-safe`

<blockquote>

## [0.1.64] - 2026-06-24

### Chore

- *(deps)* Update actions/checkout action to v7 ([#81](#81))
- *(deps)* Switch mimalloc3 to upstream microsoft/mimalloc ([#82](#82))
</blockquote>


</p></details>

---
This PR was generated with [release-plz](https://github.com/release-plz/release-plz/).
@github-actions github-actions Bot mentioned this pull request Jun 24, 2026
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