Skip to content

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

Closed
leiyue123 wants to merge 1 commit into
microsoft:dev3from
leiyue123:fix-osx-reinit-lock
Closed

fix(osx): implement introspect.reinit_lock to avoid fork() crash#1311
leiyue123 wants to merge 1 commit into
microsoft:dev3from
leiyue123:fix-osx-reinit-lock

Conversation

@leiyue123

Copy link
Copy Markdown

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.
@daanx daanx changed the base branch from dev3 to dev June 21, 2026 23:19
@daanx daanx changed the base branch from dev to dev3 June 21, 2026 23:19
@daanx

daanx commented Jun 21, 2026

Copy link
Copy Markdown
Collaborator

This is great -- I would like to merge but this commit should be made against the dev branch (I think). Can you resubmit or edit to against dev? If it is too much hassle I can also commit it manually.

@leiyue123 leiyue123 changed the base branch from dev3 to dev June 22, 2026 02:54
@leiyue123 leiyue123 changed the base branch from dev to dev3 June 22, 2026 02:59
@leiyue123

Copy link
Copy Markdown
Author

This is great -- I would like to merge but this commit should be made against the dev branch (I think). Can you resubmit or edit to against dev? If it is too much hassle I can also commit it manually.

Closing in favor of #1315 which targets dev as requested. Same commit, identical diff. Thanks @daanx!

@leiyue123 leiyue123 closed this Jun 22, 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.

2 participants