From 1271185b87fcf54afb37dc05e7e0c58e5fb8f06a Mon Sep 17 00:00:00 2001 From: Jason Evans Date: Wed, 12 Dec 2012 10:12:18 -0800 Subject: [PATCH] Fix chunk_recycle() Valgrind integration. Fix chunk_recycyle() to unconditionally inform Valgrind that returned memory is undefined. This fixes Valgrind warnings that would result from a huge allocation being freed, then recycled for use as an arena chunk. The arena code would write metadata to the chunk header, and Valgrind would consider these invalid writes. --- ChangeLog | 2 ++ src/chunk.c | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3dff01e1..374459de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -10,6 +10,8 @@ found in the git revision history: Bug fixes: - Fix "arenas.extend" mallctl to output the number of arenas. + - Fix chunk_recycyle() to unconditionally inform Valgrind that returned memory + is undefined. * 3.2.0 (November 9, 2012) diff --git a/src/chunk.c b/src/chunk.c index 1a3bb4f6..40c108a4 100644 --- a/src/chunk.c +++ b/src/chunk.c @@ -122,10 +122,9 @@ chunk_recycle(extent_tree_t *chunks_szad, extent_tree_t *chunks_ad, size_t size, } base_node_dealloc(node); } - if (zeroed == false && *zero) { - VALGRIND_MAKE_MEM_UNDEFINED(ret, size); + VALGRIND_MAKE_MEM_UNDEFINED(ret, size); + if (zeroed == false && *zero) memset(ret, 0, size); - } return (ret); }