diff options
author | Jason Evans <je@fb.com> | 2013-10-21 22:00:06 (GMT) |
---|---|---|
committer | Jason Evans <je@fb.com> | 2013-10-21 22:00:06 (GMT) |
commit | 30e7cb11186554eb3ee860856eb5b8d541d7740c (patch) | |
tree | 83ed1aad535e4c0ff3695d2a435be4f8ef66d120 /src | |
parent | f1c3da8b02489b7728d4275ac011336299eace62 (diff) | |
download | jemalloc-30e7cb11186554eb3ee860856eb5b8d541d7740c.zip jemalloc-30e7cb11186554eb3ee860856eb5b8d541d7740c.tar.gz jemalloc-30e7cb11186554eb3ee860856eb5b8d541d7740c.tar.bz2 |
Fix a data race for large allocation stats counters.
Reported by Pat Lynch.
Diffstat (limited to 'src')
-rw-r--r-- | src/tcache.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/tcache.c b/src/tcache.c index 98ed19e..88ec481 100644 --- a/src/tcache.c +++ b/src/tcache.c @@ -260,8 +260,8 @@ tcache_arena_dissociate(tcache_t *tcache) /* Unlink from list of extant tcaches. */ malloc_mutex_lock(&tcache->arena->lock); ql_remove(&tcache->arena->tcache_ql, tcache, link); - malloc_mutex_unlock(&tcache->arena->lock); tcache_stats_merge(tcache, tcache->arena); + malloc_mutex_unlock(&tcache->arena->lock); } } @@ -399,11 +399,14 @@ tcache_thread_cleanup(void *arg) } } +/* Caller must own arena->lock. */ void tcache_stats_merge(tcache_t *tcache, arena_t *arena) { unsigned i; + cassert(config_stats); + /* Merge and reset tcache stats. */ for (i = 0; i < NBINS; i++) { arena_bin_t *bin = &arena->bins[i]; |