Skip to content

fix(osx): implement introspect.reinit_lock to avoid fork() crash#1315

Merged
daanx merged 1 commit into
microsoft:devfrom
leiyue123:fix/osx-reinit-lock-dev
Jun 22, 2026
Merged

fix(osx): implement introspect.reinit_lock to avoid fork() crash#1315
daanx merged 1 commit into
microsoft:devfrom
leiyue123:fix/osx-reinit-lock-dev

Conversation

@leiyue123

Copy link
Copy Markdown

Re-submission of #1311 against dev as requested by @daanx.

Same commit, identical diff. Closing #1311.

cc @daanx


The macOS malloc zone advertises version >= 9, for which libmalloc invokes
introspect->reinit_lock from the atfork_child handler (_malloc_fork_child)
without a NULL check. The introspection struct left reinit_lock unset (NULL),
so any fork() in a process that statically links the mimalloc zone made the
child jump to address 0 and crash (EXC_BAD_ACCESS at 0x0) on macOS 15.

Provide a no-op reinit_lock: mimalloc has no zone-level locks to reinitialize
after fork.

The macOS malloc zone advertises version >= 9, for which libmalloc invokes
introspect->reinit_lock from the atfork_child handler (_malloc_fork_child)
without a NULL check. The introspection struct left reinit_lock unset (NULL),
so any fork() in a process that statically links the mimalloc zone made the
child jump to address 0 and crash (EXC_BAD_ACCESS at 0x0) on macOS 15.

Provide a no-op reinit_lock: mimalloc has no zone-level locks to reinitialize
after fork.
@leiyue123

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Tencent"

@daanx daanx merged commit 4f7d2fe into microsoft:dev Jun 22, 2026
1 check passed
@daanx

daanx commented Jun 22, 2026

Copy link
Copy Markdown
Collaborator

Thank you!

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.

2 participants