diff options
author | Florian Weimer <fweimer@redhat.com> | 2016-06-21 21:29:21 +0200 |
---|---|---|
committer | Florian Weimer <fweimer@redhat.com> | 2016-08-18 15:22:51 +0200 |
commit | 60022fbfba872422993caf6130ad4b92e74bb356 (patch) | |
tree | 84e63f2155cc1fb14efedea0898bf20579ee9553 | |
parent | 21ed68033a6732e4478926de06dd091ee7f1d4c1 (diff) | |
download | glibc-60022fbfba872422993caf6130ad4b92e74bb356.zip glibc-60022fbfba872422993caf6130ad4b92e74bb356.tar.gz glibc-60022fbfba872422993caf6130ad4b92e74bb356.tar.bz2 |
malloc: Avoid premature fallback to mmap [BZ #20284]
Before this change, the while loop in reused_arena which avoids
returning a corrupt arena would never execute its body if the selected
arena were not corrupt. As a result, result == begin after the loop,
and the function returns NULL, triggering fallback to mmap.
(cherry picked from commit a3b473373ee43a292f5ec68a7fda6b9cfb26a9b0)
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | malloc/arena.c | 10 |
2 files changed, 10 insertions, 6 deletions
@@ -1,3 +1,9 @@ +2016-06-21 Florian Weimer <fweimer@redhat.com> + + [BZ #20284] + * malloc/arena.c (reused_arena): Do not return NULL if we start + out with a non-corrupted arena. + 2016-08-17 Florian Weimer <fweimer@redhat.com> [BZ #20452] diff --git a/malloc/arena.c b/malloc/arena.c index 7c52633..5350992 100644 --- a/malloc/arena.c +++ b/malloc/arena.c @@ -938,14 +938,12 @@ reused_arena (mstate avoid_arena) { result = result->next; if (result == begin) - break; + /* We looped around the arena list. We could not find any + arena that was either not corrupted or not the one we + wanted to avoid. */ + return NULL; } - /* We could not find any arena that was either not corrupted or not the one - we wanted to avoid. */ - if (result == begin || result == avoid_arena) - return NULL; - /* No arena available without contention. Wait for the next in line. */ LIBC_PROBE (memory_arena_reuse_wait, 3, &result->mutex, result, avoid_arena); (void) mutex_lock (&result->mutex); |