mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-22 04:03:11 +00:00
Fix FreeBSD postfork child handler never being called: FreeBSD's libthr calls _malloc_postfork in both parent and child (see freebsd-src lib/libthr/thread/thr_fork.c), but jemalloc mapped it to the parent handler only. Detect the child via getpid() and route to jemalloc_postfork_child, which resets nthreads and rebuilds the descriptor queue. Remove the child_survivor_bytes vs pre_survivor_bytes comparison: on macOS where jemalloc registers as the default zone, internal allocations during the postfork handler (pthread_mutex_init) can inflate the surviving thread's tcache. Add double-fork test to verify prefork pid is refreshed correctly when a child process forks again.