diff options
author | Jason Evans <jasone@canonware.com> | 2016-06-04 02:25:13 (GMT) |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2016-06-06 04:00:02 (GMT) |
commit | 8835cf3bed1888fc0110b0c59dbf2ce1288a7a8c (patch) | |
tree | c8041f71b51b2b5625e9de4b68e3b889b82853cb /src/arena.c | |
parent | f8f0542194e2a7fb0eff8a20143a26fe4a6ea6a5 (diff) | |
download | jemalloc-8835cf3bed1888fc0110b0c59dbf2ce1288a7a8c.zip jemalloc-8835cf3bed1888fc0110b0c59dbf2ce1288a7a8c.tar.gz jemalloc-8835cf3bed1888fc0110b0c59dbf2ce1288a7a8c.tar.bz2 |
Fix locking order reversal in arena_reset().
Diffstat (limited to 'src/arena.c')
-rw-r--r-- | src/arena.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/arena.c b/src/arena.c index 32e1915..7dcf12d 100644 --- a/src/arena.c +++ b/src/arena.c @@ -917,20 +917,28 @@ arena_reset(tsd_t *tsd, arena_t *arena) /* Bins. */ for (i = 0; i < NBINS; i++) { - extent_t *slab, *next; + extent_t *slab; arena_bin_t *bin = &arena->bins[i]; malloc_mutex_lock(tsd_tsdn(tsd), &bin->lock); if (bin->slabcur != NULL) { - arena_slab_dalloc(tsd_tsdn(tsd), arena, bin->slabcur); + slab = bin->slabcur; bin->slabcur = NULL; + malloc_mutex_unlock(tsd_tsdn(tsd), &bin->lock); + arena_slab_dalloc(tsd_tsdn(tsd), arena, slab); + malloc_mutex_lock(tsd_tsdn(tsd), &bin->lock); } while ((slab = extent_heap_remove_first(&bin->slabs_nonfull)) != - NULL) + NULL) { + malloc_mutex_unlock(tsd_tsdn(tsd), &bin->lock); arena_slab_dalloc(tsd_tsdn(tsd), arena, slab); + malloc_mutex_lock(tsd_tsdn(tsd), &bin->lock); + } for (slab = qr_next(&bin->slabs_full, qr_link); slab != - &bin->slabs_full; slab = next) { - next = qr_next(slab, qr_link); + &bin->slabs_full; slab = qr_next(&bin->slabs_full, + qr_link)) { + malloc_mutex_unlock(tsd_tsdn(tsd), &bin->lock); arena_slab_dalloc(tsd_tsdn(tsd), arena, slab); + malloc_mutex_lock(tsd_tsdn(tsd), &bin->lock); } if (config_stats) { bin->stats.curregs = 0; |