Skip to content

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

Open
leiyue123 wants to merge 1 commit into
microsoft:devfrom
leiyue123:fix/osx-reinit-lock-dev
Open

fix(osx): implement introspect.reinit_lock to avoid fork() crash#1315
leiyue123 wants to merge 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"

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