mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-06-30 11:16:03 +03:00
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:
parent
00869e39a3
commit
73713fbb27
5 changed files with 43 additions and 13 deletions
|
|
@ -352,12 +352,15 @@ background_thread_create(tsd_t *tsd, unsigned arena_ind) {
|
|||
}
|
||||
|
||||
pre_reentrancy(tsd);
|
||||
malloc_mutex_unlock(tsd_tsdn(tsd), &background_thread_lock);
|
||||
/*
|
||||
* To avoid complications (besides reentrancy), create internal
|
||||
* background threads with the underlying pthread_create.
|
||||
* background threads with the underlying pthread_create, and drop
|
||||
* background_thread_lock (pthread_create may take internal locks).
|
||||
*/
|
||||
int err = pthread_create_wrapper(&info->thread, NULL,
|
||||
background_thread_entry, (void *)thread_ind);
|
||||
malloc_mutex_lock(tsd_tsdn(tsd), &background_thread_lock);
|
||||
post_reentrancy(tsd);
|
||||
|
||||
if (err != 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue