]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
malloc: Initiate tcache shutdown even without allocations [BZ #28028]
authorJeffyChen <jeffy.chen@rock-chips.com>
Fri, 2 Jul 2021 15:39:24 +0000 (17:39 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Fri, 2 Jul 2021 15:39:24 +0000 (17:39 +0200)
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>
malloc/malloc.c

index 0e2e1747e020bf2c5578a9973b7e159b04bc6c4a..bb9a1642aa543306bf9bd53bb539c90af1822b42 100644 (file)
@@ -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.  */