commit a3b473373ee43a292f5ec68a7fda6b9cfb26a9b0 Author: Florian Weimer Date: Tue Jun 21 21:29:21 2016 +0200 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. Index: glibc-2.17-c758a686/malloc/arena.c =================================================================== --- glibc-2.17-c758a686.orig/malloc/arena.c +++ glibc-2.17-c758a686/malloc/arena.c @@ -907,14 +907,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);