Open Bug 1376567 Opened 3 years ago Updated 1 year ago

Calling fork() during shutdown on Mac leads to a crash due to memory allocations

Categories

(Core :: Memory Allocator, defect, P3)

x86_64
macOS
defect

Tracking

()

People

(Reporter: gsvelto, Unassigned)

References

Details

(Keywords: crash)

This is something we've experienced dealing with the crashreporter client as well as the pingsender. Apparently fork() on Mac is doing some memory allocations (possibly related to locking) so if it gets called late enough during shutdown it crashes the parent process.
Ted, I can't find the bug where we hit this. Do you remember which one it was? It would be great to have that stack trace showing the problem in action.
Flags: needinfo?(ted)
That was bug 1356673.
Flags: needinfo?(ted)
From my reading of the crash stacks from that bug, it looked like something was going wrong with the way jemalloc hooked into the system heap. attachment 8858399 [details] shows the forked process was crashing in libsystem_malloc in nano_reinit_lock by way of libSystem_atfork_child. I don't really know enough about our jemalloc implementation or OS X's system malloc to say anything more useful here, but I'd guess that something jemalloc is doing is not fork-safe.
Mike, we spoke about this during the all-hands closing party, in case you want to have a look :)
Flags: needinfo?(mh+mozilla)
Depends on: 1416078
Blocks: 1416078
No longer depends on: 1416078
No longer blocks: 1416078
Severity: normal → critical
Keywords: crash
See Also: → 1356673
Summary: Calling fork() during shutdown on Mac leads to a crash → Calling fork() during shutdown on Mac leads to a crash due to memory allocations
Clearing the needinfo since we've moved the affected code to use posix_spawnp(). Since fork() has other issues on Mac this is probably not worth investigating.
Flags: needinfo?(mh+mozilla)
Type: enhancement → defect
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.