public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] malloc: Initiate tcache shutdown even without allocations [BZ #28028]
@ 2021-06-30  8:25 Florian Weimer
  2021-07-02  1:23 ` DJ Delorie
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Weimer @ 2021-06-30  8:25 UTC (permalink / raw)
  To: libc-alpha; +Cc: JeffyChen, DJ Delorie

From: JeffyChen <jeffy.chen@rock-chips.com>

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.

---
 malloc/malloc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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.  */


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] malloc: Initiate tcache shutdown even without allocations [BZ #28028]
  2021-06-30  8:25 [PATCH] malloc: Initiate tcache shutdown even without allocations [BZ #28028] Florian Weimer
@ 2021-07-02  1:23 ` DJ Delorie
  0 siblings, 0 replies; 2+ messages in thread
From: DJ Delorie @ 2021-07-02  1:23 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha, jeffy.chen


Florian Weimer <fweimer@redhat.com> writes:
> From: JeffyChen <jeffy.chen@rock-chips.com>
>
> 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.

LGTM
Reviewed-by: DJ Delorie <dj@redhat.com>

> ---
>  malloc/malloc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> 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.  */


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-02  1:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-30  8:25 [PATCH] malloc: Initiate tcache shutdown even without allocations [BZ #28028] Florian Weimer
2021-07-02  1:23 ` DJ Delorie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).