summary refs log tree commit diff
path: root/malloc/malloc.c
diff options
context:
space:
mode:
authorJeffyChen <jeffy.chen@rock-chips.com>2021-07-02 17:39:24 +0200
committerFlorian Weimer <fweimer@redhat.com>2021-07-02 17:39:24 +0200
commitdfec225ee1972488bb48a8b67a2c4a13010c334a (patch)
treeeb71b15d04b6e21ac7a6296a1bc35fe4d18ac4a0 /malloc/malloc.c
parent784fff6ea553da551b6a4989c94c66a69c43201d (diff)
downloadglibc-dfec225ee1972488bb48a8b67a2c4a13010c334a.tar.gz
glibc-dfec225ee1972488bb48a8b67a2c4a13010c334a.tar.xz
glibc-dfec225ee1972488bb48a8b67a2c4a13010c334a.zip
malloc: Initiate tcache shutdown even without allocations [BZ #28028]
After commit 1e26d35193efbb29239c710a4c46a64708643320 ("malloc: Fix
tcache leak after thread destruction [BZ #22111]"),
tcache_shutting_down is still not early enough.  When we detach a
thread with no tcache allocated, tcache_shutting_down would still be
false.

Reviewed-by: DJ Delorie <dj@redhat.com>
Diffstat (limited to 'malloc/malloc.c')
-rw-r--r--malloc/malloc.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 0e2e1747e0..bb9a1642aa 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -3144,12 +3144,13 @@ tcache_thread_shutdown (void)
   int i;
   tcache_perthread_struct *tcache_tmp = tcache;
 
+  tcache_shutting_down = true;
+
   if (!tcache)
     return;
 
   /* Disable the tcache and prevent it from being reinitialized.  */
   tcache = NULL;
-  tcache_shutting_down = true;
 
   /* Free all of the entries and the tcache itself back to the arena
      heap for coalescing.  */