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
@ -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…
Reference in New Issue
Block a user