Bug 703087 - (Temporarily) enable release-build assertion in isalloc_validate in release builds, to test for potential ozone_size corruption. r=khuey
authorJustin Lebar <justin.lebar@gmail.com>
Wed, 16 Nov 2011 17:48:02 -0500
changeset 80570 b5c891d2e68a015e9df6be0b09002f729dff6bb9
parent 80569 291faf6a656a14af465058729c5bd0f14e9673b0
child 80571 665d2bad0a1a82f3069894df57d24c56a0e985b2
push id21511
push userbmo@edmorley.co.uk
push dateTue, 22 Nov 2011 02:38:00 +0000
treeherdermozilla-central@b8955ff00aae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs703087
milestone11.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 703087 - (Temporarily) enable release-build assertion in isalloc_validate in release builds, to test for potential ozone_size corruption. r=khuey
memory/jemalloc/jemalloc.c
--- a/memory/jemalloc/jemalloc.c
+++ b/memory/jemalloc/jemalloc.c
@@ -984,20 +984,20 @@ struct arena_bin_s {
 
 #ifdef MALLOC_STATS
 	/* Bin statistics. */
 	malloc_bin_stats_t stats;
 #endif
 };
 
 struct arena_s {
-#ifdef MALLOC_DEBUG
+	/* For bug 703087, we're temporarily adding arena.magic to release
+	   builds. */
 	uint32_t		magic;
 #  define ARENA_MAGIC 0x947d3d24
-#endif
 
 	/* All operations on this arena require that lock be locked. */
 #ifdef MOZ_MEMORY
 	malloc_spinlock_t	lock;
 #else
 	pthread_mutex_t		lock;
 #endif
 
@@ -4327,17 +4327,25 @@ isalloc_validate(const void *ptr)
 	chunk = (arena_chunk_t *)CHUNK_ADDR2BASE(ptr);
 	if (chunk == NULL)
 		return (0);
 
 	if (malloc_rtree_get(chunk_rtree, (uintptr_t)chunk) == NULL)
 		return (0);
 
 	if (chunk != ptr) {
-		assert(chunk->arena->magic == ARENA_MAGIC);
+		/* For bug 703087, we've temporarily made what is normally a
+		   debug-only assertion here into a fatal assertion. */
+		if (chunk->arena->magic != ARENA_MAGIC) {
+			_malloc_message("isalloc_validate called with invalid pointer. "
+			                "Crashing...\n", "", "", "");
+			char* boom = (char*) 0;
+			*boom = 1;
+		}
+
 		return (arena_salloc(ptr));
 	} else {
 		size_t ret;
 		extent_node_t *node;
 		extent_node_t key;
 
 		/* Chunk. */
 		key.addr = (void *)chunk;
@@ -4837,20 +4845,19 @@ arena_new(arena_t *arena)
 
 		prev_run_size = arena_bin_run_size_calc(bin, prev_run_size);
 
 #ifdef MALLOC_STATS
 		memset(&bin->stats, 0, sizeof(malloc_bin_stats_t));
 #endif
 	}
 
-#ifdef MALLOC_DEBUG
+        /* For bug 703087, we're temporarily adding arena->magic for release
+           builds. */
 	arena->magic = ARENA_MAGIC;
-#endif
-
 	return (false);
 }
 
 /* Create a new arena and insert it into the arenas array at index ind. */
 static arena_t *
 arenas_extend(unsigned ind)
 {
 	arena_t *ret;