This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch v1] malloc: fix set_max_fast "impossibly small" value

>From 83035919da9208a7e6666bdde60e110e2e301553 Mon Sep 17 00:00:00 2001
From: DJ Delorie <>
Date: Wed, 30 Oct 2019 18:03:14 -0400
Subject: Base max_fast on alignment, not width, of bins

set_max_fast set the "impossibly small" value based on,
eventually, MALLOC_ALIGNMENT.  The comparisons for the smallest
chunk used, eventuall, MIN_CHUNK_SIZE.  Note that i386
is the only platform where these are the same, so a smallest
chunk *would* be put in a no-fastbins fastbin.

This change calculates the "impossibly small" value
based on MIN_CHUNK_SIZE instead, so that we can know it will
always be impossibly small.

diff --git a/malloc/malloc.c b/malloc/malloc.c
index 5d3e82a8f6..70cc35a473 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -1621,7 +1621,7 @@ static INTERNAL_SIZE_T global_max_fast;
 #define set_max_fast(s) \
   global_max_fast = (((s) == 0)						      \
-                     ? SMALLBIN_WIDTH : ((s + SIZE_SZ) & ~MALLOC_ALIGN_MASK))
+                     ? MIN_CHUNK_SIZE / 2 : ((s + SIZE_SZ) & ~MALLOC_ALIGN_MASK))
 static inline INTERNAL_SIZE_T
 get_max_fast (void)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]