public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [patch v1] malloc: set NON_MAIN_ARENA flag for reclaimed memalign chunk (BZ #30101)
@ 2023-04-03 22:12 DJ Delorie
  2023-04-04 10:26 ` Florian Weimer
  2023-04-04 17:54 ` Carlos O'Donell
  0 siblings, 2 replies; 10+ messages in thread
From: DJ Delorie @ 2023-04-03 22:12 UTC (permalink / raw)
  To: libc-alpha


From 61bd502ecac4d63f04c74bfc491ca675660d26b7 Mon Sep 17 00:00:00 2001
From: DJ Delorie <dj@redhat.com>
Date: Mon, 3 Apr 2023 17:33:03 -0400
Subject: malloc: set NON_MAIN_ARENA flag for reclaimed memalign chunk (BZ #30101)

Based on these comments in malloc.c:

   size field is or'ed with NON_MAIN_ARENA if the chunk was obtained
   from a non-main arena.  This is only set immediately before handing
   the chunk to the user, if necessary.

   The NON_MAIN_ARENA flag is never set for unsorted chunks, so it
   does not have to be taken into account in size comparisons.

When we pull a chunk off the unsorted list (or any list) we need to
make sure that flag is set properly before returning the chunk.

diff --git a/malloc/malloc.c b/malloc/malloc.c
index 0315ac5d16..66e7ca57dd 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -5147,6 +5147,8 @@ _int_memalign (mstate av, size_t alignment, size_t bytes)
       p = victim;
       m = chunk2mem (p);
       set_inuse (p);
+      if (av != &main_arena)
+	set_non_main_arena (p);
     }
   else
     {


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

end of thread, other threads:[~2023-04-12 16:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-03 22:12 [patch v1] malloc: set NON_MAIN_ARENA flag for reclaimed memalign chunk (BZ #30101) DJ Delorie
2023-04-04 10:26 ` Florian Weimer
2023-04-04 17:54 ` Carlos O'Donell
2023-04-05  2:27   ` [patch v2] " DJ Delorie
2023-04-05  6:14     ` Carlos O'Donell
2023-04-05 17:23       ` DJ Delorie
2023-04-06 17:09         ` Florian Weimer
2023-04-12  4:00     ` [patch v3] " DJ Delorie
2023-04-12 13:11       ` Cristian Rodríguez
2023-04-12 16:46         ` 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).