public inbox for libc-stable@sourceware.org
 help / color / mirror / Atom feed
* [2.23 COMMITTED] malloc: Avoid premature fallback to mmap [BZ #20284]
@ 2016-01-01  0:00 Florian Weimer
  0 siblings, 0 replies; only message in thread
From: Florian Weimer @ 2016-01-01  0:00 UTC (permalink / raw)
  To: libc-stable

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)

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.

diff --git a/malloc/arena.c b/malloc/arena.c
index 0e5cc0f..232b6a2 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -795,14 +795,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);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-08-18 13:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-01  0:00 [2.23 COMMITTED] malloc: Avoid premature fallback to mmap [BZ #20284] Florian Weimer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).