From 161cc3e840ca8e3cfe8fbf558ecc48406dd9299f Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 23 Sep 2020 11:07:04 +0930 Subject: [PATCH] memleak: make "_notleak" names less powerful. They previously prevented any child from being detected as leaks, now they just mark the tal allocation itself as not being a leak. Signed-off-by: Rusty Russell --- common/configdir.c | 3 +++ common/memleak.c | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/common/configdir.c b/common/configdir.c index 15027e03b..e47777625 100644 --- a/common/configdir.c +++ b/common/configdir.c @@ -122,6 +122,9 @@ static void parse_include(const char *filename, bool must_exist, bool early, /* Only valid forms are "foo" and "foo=bar" */ all_args[i] = tal_fmt(all_args, "--%s", lines[i]); } + /* This isn't a leak either */ + if (all_args[i]) + tal_set_name(all_args[i], TAL_LABEL(config_notleak, "")); } /* diff --git a/common/memleak.c b/common/memleak.c index 84c3bb6f7..13e336996 100644 --- a/common/memleak.c +++ b/common/memleak.c @@ -77,10 +77,6 @@ static void children_into_htable(const void *exclude1, const void *exclude2, if (strends(name, "struct io_plan *[]") && !tal_parent(i)) continue; - /* Other notleak internals. */ - if (strends(name, "_notleak")) - continue; - /* Don't add tmpctx. */ if (streq(name, "tmpctx")) continue; @@ -244,6 +240,9 @@ static void call_memleak_helpers(struct htable *memtable, const tal_t *p) else pointer_referenced(memtable, p); memleak_scan_region(memtable, p, tal_bytelen(p)); + } else if (name && strends(name, "_notleak")) { + pointer_referenced(memtable, i); + call_memleak_helpers(memtable, i); } else { call_memleak_helpers(memtable, i); }