From 57ed894f8ac154d30faf9449a76d2792cdad3850 Mon Sep 17 00:00:00 2001 From: Qi Wang Date: Thu, 22 Sep 2016 09:13:45 -0700 Subject: [PATCH] Fix arena_bind(). When tsd is not in nominal state (e.g. during thread termination), we should not increment nthreads. --- src/jemalloc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/jemalloc.c b/src/jemalloc.c index 5d1f4937..c1ecc73c 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -455,15 +455,16 @@ arena_bind(tsd_t *tsd, unsigned ind, bool internal) { arena_t *arena; + if (!tsd_nominal(tsd)) + return; + arena = arena_get(tsd_tsdn(tsd), ind, false); arena_nthreads_inc(arena, internal); - if (tsd_nominal(tsd)) { - if (internal) - tsd_iarena_set(tsd, arena); - else - tsd_arena_set(tsd, arena); - } + if (internal) + tsd_iarena_set(tsd, arena); + else + tsd_arena_set(tsd, arena); } void