mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-04-21 02:12:15 +03:00
Return early in _malloc_{pre,post}fork() if uninitialized.
Avoid mutex operations in _malloc_{pre,post}fork() unless jemalloc has
been initialized.
Reported by David Xu.
This commit is contained in:
parent
d8ceef6c55
commit
58ad1e4956
1 changed files with 14 additions and 0 deletions
|
|
@ -1621,6 +1621,12 @@ _malloc_prefork(void)
|
|||
{
|
||||
unsigned i;
|
||||
|
||||
#ifdef JEMALLOC_MUTEX_INIT_CB
|
||||
if (malloc_initialized == false)
|
||||
return;
|
||||
#endif
|
||||
assert(malloc_initialized);
|
||||
|
||||
/* Acquire all mutexes in a safe order. */
|
||||
malloc_mutex_prefork(&arenas_lock);
|
||||
for (i = 0; i < narenas; i++) {
|
||||
|
|
@ -1642,6 +1648,12 @@ _malloc_postfork(void)
|
|||
{
|
||||
unsigned i;
|
||||
|
||||
#ifdef JEMALLOC_MUTEX_INIT_CB
|
||||
if (malloc_initialized == false)
|
||||
return;
|
||||
#endif
|
||||
assert(malloc_initialized);
|
||||
|
||||
/* Release all mutexes, now that fork() has completed. */
|
||||
chunk_dss_postfork_parent();
|
||||
huge_postfork_parent();
|
||||
|
|
@ -1658,6 +1670,8 @@ jemalloc_postfork_child(void)
|
|||
{
|
||||
unsigned i;
|
||||
|
||||
assert(malloc_initialized);
|
||||
|
||||
/* Release all mutexes, now that fork() has completed. */
|
||||
chunk_dss_postfork_child();
|
||||
huge_postfork_child();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue