mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-04-29 14:22:14 +03:00
Fix locking order reversal in arena_reset().
This commit is contained in:
parent
f8f0542194
commit
8835cf3bed
1 changed files with 13 additions and 5 deletions
18
src/arena.c
18
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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue