summaryrefslogtreecommitdiffstats
path: root/src/quarantine.c
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2013-12-17 23:14:36 (GMT)
committerJason Evans <jasone@canonware.com>2013-12-17 23:19:12 (GMT)
commit0d6c5d8bd0d866a0ce4ce321259cec65d6459821 (patch)
tree083566d27a62252feb2c329c9dee1ee4745a140e /src/quarantine.c
parenteca367b77909ebd649fbd0430e1e9b80dded14e0 (diff)
downloadjemalloc-0d6c5d8bd0d866a0ce4ce321259cec65d6459821.zip
jemalloc-0d6c5d8bd0d866a0ce4ce321259cec65d6459821.tar.gz
jemalloc-0d6c5d8bd0d866a0ce4ce321259cec65d6459821.tar.bz2
Add quarantine unit tests.
Verify that freed regions are quarantined, and that redzone corruption is detected. Introduce a testing idiom for intercepting/replacing internal functions. In this case the replaced function is ordinarily a static function, but the idiom should work similarly for library-private functions.
Diffstat (limited to 'src/quarantine.c')
-rw-r--r--src/quarantine.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/quarantine.c b/src/quarantine.c
index f96a948..5431511 100644
--- a/src/quarantine.c
+++ b/src/quarantine.c
@@ -141,8 +141,17 @@ quarantine(void *ptr)
obj->usize = usize;
quarantine->curbytes += usize;
quarantine->curobjs++;
- if (opt_junk)
- memset(ptr, 0x5a, usize);
+ if (config_fill && opt_junk) {
+ /*
+ * Only do redzone validation if Valgrind isn't in
+ * operation.
+ */
+ if ((config_valgrind == false || opt_valgrind == false)
+ && usize <= SMALL_MAXCLASS)
+ arena_quarantine_junk_small(ptr, usize);
+ else
+ memset(ptr, 0x5a, usize);
+ }
} else {
assert(quarantine->curbytes == 0);
idalloc(ptr);