]> git.ipfire.org Git - thirdparty/glibc.git/commit
malloc: set NON_MAIN_ARENA flag for reclaimed memalign chunk (BZ #30101)
authorDJ Delorie <dj@redhat.com>
Mon, 3 Apr 2023 21:33:03 +0000 (17:33 -0400)
committerDJ Delorie <dj@redhat.com>
Tue, 18 Apr 2023 14:58:42 +0000 (10:58 -0400)
commite5524ef335dc8e28d64cc376d57c219e566fcf53
tree92fc25b1af0bbc50710619d42aeba02c17baa0c7
parent8895a99c10349e5b0bb57b64c229389169a312e0
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.

Use the rounded-up size for chunk_ok_for_memalign()

Do not scan the arena for reusable chunks if there's no arena.

Account for chunk overhead when determining if a chunk is a reuse
candidate.

mcheck interferes with memalign, so skip mcheck variants of
memalign tests.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
malloc/Makefile
malloc/malloc.c
malloc/tst-memalign-2.c
malloc/tst-memalign-3.c [new file with mode: 0644]