diff mbox

malloc: Avoid premature fallback to mmap [BZ #20284]

Message ID 20160621152118.20F8F402276E4@oldenburg.str.redhat.com
State New
Headers show

Commit Message

Florian Weimer June 21, 2016, 3:21 p.m. UTC
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.

Comments

DJ Delorie June 21, 2016, 5:55 p.m. UTC | #1
Ok with me.
Siddhesh Poyarekar June 21, 2016, 6:55 p.m. UTC | #2
On Tue, Jun 21, 2016 at 05:21:18PM +0200, Florian Weimer wrote:
> 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.
> 

Looks OK to me.  The commit log could however use a nice explanation
of what the problem is.

Siddhesh
diff mbox

Patch

diff --git a/malloc/arena.c b/malloc/arena.c
index ed5a4d5..229783f 100644
--- a/malloc/arena.c
+++ b/malloc/arena.c
@@ -771,14 +771,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);