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.
This commit is contained in:
Jason Evans 2012-12-12 10:12:18 -08:00
parent 6eb84fbe31
commit 1271185b87
2 changed files with 4 additions and 3 deletions

View File

@ -10,6 +10,8 @@ found in the git revision history:
Bug fixes: Bug fixes:
- Fix "arenas.extend" mallctl to output the number of arenas. - 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) * 3.2.0 (November 9, 2012)

View File

@ -122,10 +122,9 @@ chunk_recycle(extent_tree_t *chunks_szad, extent_tree_t *chunks_ad, size_t size,
} }
base_node_dealloc(node); 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); memset(ret, 0, size);
}
return (ret); return (ret);
} }