Bug 1875768 - Clear mMainThreadId after a fork in the child r=glandium, a=dmeehan

Differential Revision: https://phabricator.services.mozilla.com/D212230
This commit is contained in:
Paul Bone 2024-07-04 03:51:07 +00:00
parent ab6a089199
commit 40ddfb59b9

View file

@ -1402,11 +1402,10 @@ class ArenaCollection {
}
// After a fork set the new thread ID in the child.
void PostForkFixMainThread() {
if (mMainThreadId.isSome()) {
// Only if the main thread has been defined.
mMainThreadId = Some(GetThreadId());
}
void ResetMainThread() {
// The post fork handler in the child can run from a MacOS worker thread,
// so we can't set our main thread to it here. Instead we have to clear it.
mMainThreadId = Nothing();
}
void SetMainThread() {
@ -5217,7 +5216,7 @@ void _malloc_postfork_parent(void) MOZ_NO_THREAD_SAFETY_ANALYSIS {
FORK_HOOK
void _malloc_postfork_child(void) {
// Do this before iterating over the arenas.
gArenas.PostForkFixMainThread();
gArenas.ResetMainThread();
// Reinitialize all mutexes, now that fork() has completed.
huge_mtx.Init();