diff options
author | Cosmin Paraschiv <cparaschiv@ixiacom.com> | 2016-01-11 19:05:00 (GMT) |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2016-01-11 19:10:39 (GMT) |
commit | 9cb481a73f6d2b518f695a669c1f850e477fdd2c (patch) | |
tree | 29050f32b7d56252fbba33d8d43080a94dd9eb06 /src/jemalloc.c | |
parent | 43de1b3ebc928fa0884422ccd0a2e9cd233d1059 (diff) | |
download | jemalloc-9cb481a73f6d2b518f695a669c1f850e477fdd2c.zip jemalloc-9cb481a73f6d2b518f695a669c1f850e477fdd2c.tar.gz jemalloc-9cb481a73f6d2b518f695a669c1f850e477fdd2c.tar.bz2 |
Call malloc_test_boot0() from malloc_init_hard_recursible().
When using LinuxThreads, malloc bootstrapping deadlocks, since
malloc_tsd_boot0() ends up calling pthread_setspecific(), which causes
recursive allocation. Fix it by moving the malloc_tsd_boot0() call to
malloc_init_hard_recursible().
The deadlock was introduced by 8bb3198f72fc7587dc93527f9f19fb5be52fa553
(Refactor/fix arenas manipulation.), when tsd_boot() was split and the
top half, tsd_boot0(), got an extra tsd_wrapper_set() call.
Diffstat (limited to 'src/jemalloc.c')
-rw-r--r-- | src/jemalloc.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/jemalloc.c b/src/jemalloc.c index eed6331..fab0eb0 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -1276,26 +1276,37 @@ malloc_init_hard_a0(void) * * init_lock must be held. */ -static void +static bool malloc_init_hard_recursible(void) { + bool ret = false; malloc_init_state = malloc_init_recursible; malloc_mutex_unlock(&init_lock); + /* LinuxThreads' pthread_setspecific() allocates. */ + if (malloc_tsd_boot0()) { + ret = true; + goto label_return; + } + ncpus = malloc_ncpus(); #if (!defined(JEMALLOC_MUTEX_INIT_CB) && !defined(JEMALLOC_ZONE) \ && !defined(_WIN32) && !defined(__native_client__)) - /* LinuxThreads's pthread_atfork() allocates. */ + /* LinuxThreads' pthread_atfork() allocates. */ if (pthread_atfork(jemalloc_prefork, jemalloc_postfork_parent, jemalloc_postfork_child) != 0) { + ret = true; malloc_write("<jemalloc>: Error in pthread_atfork()\n"); if (opt_abort) abort(); } #endif + +label_return: malloc_mutex_lock(&init_lock); + return (ret); } /* init_lock must be held. */ @@ -1365,17 +1376,17 @@ malloc_init_hard(void) malloc_mutex_unlock(&init_lock); return (true); } - if (malloc_tsd_boot0()) { + + if (malloc_init_hard_recursible()) { malloc_mutex_unlock(&init_lock); return (true); } + if (config_prof && prof_boot2()) { malloc_mutex_unlock(&init_lock); return (true); } - malloc_init_hard_recursible(); - if (malloc_init_hard_finish()) { malloc_mutex_unlock(&init_lock); return (true); |