Drop high rank locks when creating threads.

Avoid holding arenas_lock and background_thread_lock when creating background
threads, because pthread_create may take internal locks, and potentially cause
deadlock with jemalloc internal locks.
This commit is contained in:
Qi Wang 2017-06-07 15:49:09 -07:00 committed by Qi Wang
parent 00869e39a3
commit 73713fbb27
5 changed files with 43 additions and 13 deletions

View file

@ -2050,17 +2050,6 @@ arena_new(tsdn_t *tsdn, unsigned ind, extent_hooks_t *extent_hooks) {
hooks_arena_new_hook();
}
post_reentrancy(tsdn_tsd(tsdn));
/* background_thread_create() handles reentrancy internally. */
if (have_background_thread) {
bool err;
malloc_mutex_lock(tsdn, &background_thread_lock);
err = background_thread_create(tsdn_tsd(tsdn), ind);
malloc_mutex_unlock(tsdn, &background_thread_lock);
if (err) {
goto label_error;
}
}
}
return arena;