summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2017-04-27 22:51:35 (GMT)
committerJason Evans <jasone@canonware.com>2017-04-29 16:24:12 (GMT)
commitc86c8f4ffbf8c118203f7327610a2ad80cf9622c (patch)
tree88d2dd9f195a744e2da0f1f1cad9f718abd7872f /test/unit
parentb9ab04a191dbcb9246d5180fc7ae822a85861939 (diff)
downloadjemalloc-c86c8f4ffbf8c118203f7327610a2ad80cf9622c.zip
jemalloc-c86c8f4ffbf8c118203f7327610a2ad80cf9622c.tar.gz
jemalloc-c86c8f4ffbf8c118203f7327610a2ad80cf9622c.tar.bz2
Add extent_destroy_t and use it during arena destruction.
Add the extent_destroy_t extent destruction hook to extent_hooks_t, and use it during arena destruction. This hook explicitly communicates to the callee that the extent must be destroyed or tracked for later reuse, lest it be permanently leaked. Prior to this change, retained extents could unintentionally be leaked if extent retention was enabled. This resolves #560.
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/arena_reset.c1
-rw-r--r--test/unit/base.c8
2 files changed, 8 insertions, 1 deletions
diff --git a/test/unit/arena_reset.c b/test/unit/arena_reset.c
index 5d6c1a7..d169832 100644
--- a/test/unit/arena_reset.c
+++ b/test/unit/arena_reset.c
@@ -278,6 +278,7 @@ static extent_hooks_t hooks_orig;
static extent_hooks_t hooks_unmap = {
extent_alloc_hook,
extent_dalloc_unmap, /* dalloc */
+ extent_destroy_hook,
extent_commit_hook,
extent_decommit_hook,
extent_purge_lazy_hook,
diff --git a/test/unit/base.c b/test/unit/base.c
index f498394..5dc42f0 100644
--- a/test/unit/base.c
+++ b/test/unit/base.c
@@ -5,6 +5,7 @@
static extent_hooks_t hooks_null = {
extent_alloc_hook,
NULL, /* dalloc */
+ NULL, /* destroy */
NULL, /* commit */
NULL, /* decommit */
NULL, /* purge_lazy */
@@ -16,6 +17,7 @@ static extent_hooks_t hooks_null = {
static extent_hooks_t hooks_not_null = {
extent_alloc_hook,
extent_dalloc_hook,
+ extent_destroy_hook,
NULL, /* commit */
extent_decommit_hook,
extent_purge_lazy_hook,
@@ -59,6 +61,7 @@ TEST_BEGIN(test_base_hooks_null) {
extent_hooks_prep();
try_dalloc = false;
+ try_destroy = true;
try_decommit = false;
try_purge_lazy = false;
try_purge_forced = false;
@@ -98,6 +101,7 @@ TEST_BEGIN(test_base_hooks_not_null) {
extent_hooks_prep();
try_dalloc = false;
+ try_destroy = true;
try_decommit = false;
try_purge_lazy = false;
try_purge_forced = false;
@@ -194,15 +198,17 @@ TEST_BEGIN(test_base_hooks_not_null) {
}
}
- called_dalloc = called_decommit = called_purge_lazy =
+ called_dalloc = called_destroy = called_decommit = called_purge_lazy =
called_purge_forced = false;
base_delete(base);
assert_true(called_dalloc, "Expected dalloc call");
+ assert_true(!called_destroy, "Unexpected destroy call");
assert_true(called_decommit, "Expected decommit call");
assert_true(called_purge_lazy, "Expected purge_lazy call");
assert_true(called_purge_forced, "Expected purge_forced call");
try_dalloc = true;
+ try_destroy = true;
try_decommit = true;
try_purge_lazy = true;
try_purge_forced = true;