]> sourceware.org Git - glibc.git/commitdiff
malloc: Avoid taggig mmaped memory on free
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Thu, 4 Feb 2021 11:52:14 +0000 (11:52 +0000)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Fri, 26 Mar 2021 11:03:06 +0000 (11:03 +0000)
Either the memory belongs to the dumped area, in which case we don't
want to tag (the dumped area has the same tag as malloc internal data
so tagging is unnecessary, but chunks there may not have the right
alignment for the tag granule), or the memory will be unmapped
immediately (and thus tagging is not useful).

Reviewed-by: DJ Delorie <dj@redhat.com>
malloc/malloc.c

index 9dd811b26a3e1efe32671d61fd3337c3139dc8a6..339304269c88c4c9ab15dce90f4c41fe9978b6f1 100644 (file)
@@ -3284,9 +3284,6 @@ __libc_free (void *mem)
 
   p = mem2chunk (mem);
 
-  /* Mark the chunk as belonging to the library again.  */
-  (void)TAG_REGION (chunk2rawmem (p), CHUNK_AVAILABLE_SIZE (p) - CHUNK_HDR_SZ);
-
   if (chunk_is_mmapped (p))                       /* release mmapped memory. */
     {
       /* See if the dynamic brk/mmap threshold needs adjusting.
@@ -3307,6 +3304,10 @@ __libc_free (void *mem)
     {
       MAYBE_INIT_TCACHE ();
 
+      /* Mark the chunk as belonging to the library again.  */
+      (void)TAG_REGION (chunk2rawmem (p),
+                       CHUNK_AVAILABLE_SIZE (p) - CHUNK_HDR_SZ);
+
       ar_ptr = arena_for_chunk (p);
       _int_free (ar_ptr, p, 0);
     }
This page took 0.047275 seconds and 5 git commands to generate.