Bug 432894: X related valgrind | jemalloc - startup errors, r=bclary,r=benjamin
authorJason Evans <jasone@canonware.com>
Fri, 20 Jun 2008 10:34:41 -0700
changeset 15457 082914aa43724f1dae737065a29cdb98573b18e0
parent 15456 38972d94e6312cca26dc09bb1d8ac4a9bec84b1c
child 15458 663c51189e98112e5cf25f91c3c818e715500b13
push idunknown
push userunknown
push dateunknown
reviewersbclary, benjamin
bugs432894
milestone1.9.1a1pre
Bug 432894: X related valgrind | jemalloc - startup errors, r=bclary,r=benjamin Fix bugs in jemalloc's valgrind support.
memory/jemalloc/jemalloc.c
--- a/memory/jemalloc/jemalloc.c
+++ b/memory/jemalloc/jemalloc.c
@@ -2958,18 +2958,24 @@ arena_run_split(arena_t *arena, arena_ru
 #  endif
 		}
 #endif
 
 		/* Zero if necessary. */
 		if (zero) {
 			if ((chunk->map[run_ind + i] & CHUNK_MAP_UNTOUCHED)
 			    == 0) {
+				VALGRIND_MALLOCLIKE_BLOCK((void *)((uintptr_t)
+				    chunk + ((run_ind + i) << pagesize_2pow)),
+				    pagesize, 0, false);
 				memset((void *)((uintptr_t)chunk + ((run_ind
 				    + i) << pagesize_2pow)), 0, pagesize);
+				VALGRIND_FREELIKE_BLOCK((void *)((uintptr_t)
+				    chunk + ((run_ind + i) << pagesize_2pow)),
+				    0);
 				/* CHUNK_MAP_UNTOUCHED is cleared below. */
 			}
 		}
 
 		/* Update dirty page accounting. */
 		if (chunk->map[run_ind + i] & CHUNK_MAP_DIRTY) {
 			chunk->ndirty--;
 			arena->ndirty--;
@@ -3398,17 +3404,17 @@ arena_bin_nonfull_run_get(arena_t *arena
 	/* No existing runs have any space available. */
 
 	/* Allocate a new run. */
 	run = arena_run_alloc(arena, bin->run_size, true, false);
 	if (run == NULL)
 		return (NULL);
 
 	VALGRIND_MALLOCLIKE_BLOCK(run, sizeof(arena_run_t) + (sizeof(unsigned) *
-	    bin->regs_mask_nelms - 1), 0, false);
+	    (bin->regs_mask_nelms - 1)), 0, false);
 
 	/* Initialize run internals. */
 	run->bin = bin;
 
 	for (i = 0; i < bin->regs_mask_nelms - 1; i++)
 		run->regs_mask[i] = UINT_MAX;
 	remainder = bin->nregs & ((1U << (SIZEOF_INT_2POW + 3)) - 1);
 	if (remainder == 0)