diff --git a/common/memleak.c b/common/memleak.c index 128b23eab..3828fa28f 100644 --- a/common/memleak.c +++ b/common/memleak.c @@ -41,7 +41,7 @@ static bool pointer_referenced(struct htable *memtable, const void *p) return htable_del(memtable, hash_ptr(p, NULL), p); } -static void children_into_htable(const void *exclude, +static void children_into_htable(const void *exclude1, const void *exclude2, struct htable *memtable, const tal_t *p) { const tal_t *i; @@ -49,7 +49,7 @@ static void children_into_htable(const void *exclude, for (i = tal_first(p); i; i = tal_next(i)) { const char *name = tal_name(i); - if (p == exclude) + if (p == exclude1 || p == exclude2) continue; if (name) { @@ -63,17 +63,19 @@ static void children_into_htable(const void *exclude, continue; } htable_add(memtable, hash_ptr(i, NULL), i); - children_into_htable(exclude, memtable, i); + children_into_htable(exclude1, exclude2, memtable, i); } } -struct htable *memleak_enter_allocations(const tal_t *ctx, const void *exclude) +struct htable *memleak_enter_allocations(const tal_t *ctx, + const void *exclude1, + const void *exclude2) { struct htable *memtable = tal(ctx, struct htable); htable_init(memtable, hash_ptr, NULL); /* First, add all pointers off NULL to table. */ - children_into_htable(exclude, memtable, NULL); + children_into_htable(exclude1, exclude2, memtable, NULL); tal_add_destructor(memtable, htable_clear); return memtable; diff --git a/common/memleak.h b/common/memleak.h index 0858f40ed..cd990fb58 100644 --- a/common/memleak.h +++ b/common/memleak.h @@ -26,7 +26,9 @@ void memleak_init(const tal_t *root, struct backtrace_state *bstate); void memleak_cleanup(void); /* Allocate a htable with all the memory we've allocated. */ -struct htable *memleak_enter_allocations(const tal_t *ctx, const void *exclude); +struct htable *memleak_enter_allocations(const tal_t *ctx, + const void *exclude1, + const void *exclude2); /* Remove any pointers to memory under root */ void memleak_remove_referenced(struct htable *memtable, const void *root); diff --git a/lightningd/memdump.c b/lightningd/memdump.c index 2c138c9fd..05acb71db 100644 --- a/lightningd/memdump.c +++ b/lightningd/memdump.c @@ -106,8 +106,8 @@ static void scan_mem(struct command *cmd, const tal_t *i; const uintptr_t *backtrace; - /* Enter everything, except this cmd. */ - memtable = memleak_enter_allocations(cmd, cmd); + /* Enter everything, except this cmd and its jcon */ + memtable = memleak_enter_allocations(cmd, cmd, cmd->jcon); /* First delete known false positives. */ chaintopology_mark_pointers_used(memtable, ld->topology);