Fix locking order reversal in arena_reset().
This commit is contained in:
parent
f8f0542194
commit
8835cf3bed
18
src/arena.c
18
src/arena.c
@ -917,20 +917,28 @@ arena_reset(tsd_t *tsd, arena_t *arena)
|
|||||||
|
|
||||||
/* Bins. */
|
/* Bins. */
|
||||||
for (i = 0; i < NBINS; i++) {
|
for (i = 0; i < NBINS; i++) {
|
||||||
extent_t *slab, *next;
|
extent_t *slab;
|
||||||
arena_bin_t *bin = &arena->bins[i];
|
arena_bin_t *bin = &arena->bins[i];
|
||||||
malloc_mutex_lock(tsd_tsdn(tsd), &bin->lock);
|
malloc_mutex_lock(tsd_tsdn(tsd), &bin->lock);
|
||||||
if (bin->slabcur != NULL) {
|
if (bin->slabcur != NULL) {
|
||||||
arena_slab_dalloc(tsd_tsdn(tsd), arena, bin->slabcur);
|
slab = bin->slabcur;
|
||||||
bin->slabcur = NULL;
|
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)) !=
|
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);
|
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 !=
|
for (slab = qr_next(&bin->slabs_full, qr_link); slab !=
|
||||||
&bin->slabs_full; slab = next) {
|
&bin->slabs_full; slab = qr_next(&bin->slabs_full,
|
||||||
next = qr_next(slab, qr_link);
|
qr_link)) {
|
||||||
|
malloc_mutex_unlock(tsd_tsdn(tsd), &bin->lock);
|
||||||
arena_slab_dalloc(tsd_tsdn(tsd), arena, slab);
|
arena_slab_dalloc(tsd_tsdn(tsd), arena, slab);
|
||||||
|
malloc_mutex_lock(tsd_tsdn(tsd), &bin->lock);
|
||||||
}
|
}
|
||||||
if (config_stats) {
|
if (config_stats) {
|
||||||
bin->stats.curregs = 0;
|
bin->stats.curregs = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user