memory/jemalloc/0005-Bug-1121314-Avoid-needing-the-arena-in-chunk_alloc_d.patch
author Ryan VanderMeulen <ryanvm@gmail.com>
Thu, 25 Jun 2015 19:48:42 -0400
changeset 281060 1a326aaaba371e18e090f98ca1c4474bbdce2fca
parent 250829 dbd00d4ec628c260a146157235ec3bd7b3c9dfec
permissions -rw-r--r--
Backed out changeset 8b4e4083639e (bug 1171931) for B2G debug emulator bustage.

From 722400adde3b4cb307fdc310e6296e10e6ace7ae Mon Sep 17 00:00:00 2001
From: Mike Hommey <mh+mozilla@glandium.org>
Date: Wed, 14 Jan 2015 12:49:24 +0900
Subject: [PATCH] Bug 1121314 - Avoid needing the arena in chunk_alloc_default
 to avoid possible infinite loops involving a0malloc

---
 src/chunk.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/src/chunk.c b/src/chunk.c
index 7926452..32e659c 100644
--- a/src/chunk.c
+++ b/src/chunk.c
@@ -247,27 +247,32 @@ chunk_alloc_arena(chunk_alloc_t *chunk_alloc, chunk_dalloc_t *chunk_dalloc,
 	return (ret);
 }
 
 /* Default arena chunk allocation routine in the absence of user override. */
 void *
 chunk_alloc_default(void *new_addr, size_t size, size_t alignment, bool *zero,
     unsigned arena_ind)
 {
-	arena_t *arena;
+	dss_prec_t dss_prec = dss_prec_disabled;
 
-	arena = arena_get(tsd_fetch(), arena_ind, false, true);
-	/*
-	 * The arena we're allocating on behalf of must have been initialized
-	 * already.
-	 */
-	assert(arena != NULL);
+	if (have_dss) {
+		arena_t *arena;
+
+		arena = arena_get(tsd_fetch(), arena_ind, false, true);
+		/*
+		 * The arena we're allocating on behalf of must have been
+		 * initialized already.
+		 */
+		assert(arena != NULL);
+		dss_prec = arena->dss_prec;
+	}
 
 	return (chunk_alloc_core(new_addr, size, alignment, false, zero,
-	    arena->dss_prec));
+	    dss_prec));
 }
 
 static void
 chunk_record(extent_tree_t *chunks_szad, extent_tree_t *chunks_ad, void *chunk,
     size_t size)
 {
 	bool unzeroed;
 	extent_node_t *xnode, *node, *prev, *xprev, key;
-- 
2.2.1.dirty