diff --git a/common/memleak.c b/common/memleak.c index 13e336996..03a7d96c3 100644 --- a/common/memleak.c +++ b/common/memleak.c @@ -256,11 +256,13 @@ struct htable *memleak_enter_allocations(const tal_t *ctx, struct htable *memtable = tal(ctx, struct htable); htable_init(memtable, hash_ptr, NULL); - /* First, add all pointers off NULL to table. */ - children_into_htable(exclude1, exclude2, memtable, NULL); + if (memleak_track) { + /* First, add all pointers off NULL to table. */ + children_into_htable(exclude1, exclude2, memtable, NULL); - /* Iterate and call helpers to eliminate hard-to-get references. */ - call_memleak_helpers(memtable, NULL); + /* Iterate and call helpers to eliminate hard-to-get references. */ + call_memleak_helpers(memtable, NULL); + } tal_add_destructor(memtable, htable_clear); return memtable; diff --git a/contrib/pyln-testing/pyln/testing/utils.py b/contrib/pyln-testing/pyln/testing/utils.py index 48b0b8a6d..be34ba7f7 100644 --- a/contrib/pyln-testing/pyln/testing/utils.py +++ b/contrib/pyln-testing/pyln/testing/utils.py @@ -584,11 +584,13 @@ class LightningNode(object): # Don't run --version on every subdaemon if we're valgrinding and slow. if SLOW_MACHINE and VALGRIND: self.daemon.opts["dev-no-version-checks"] = None - self.daemon.env["LIGHTNINGD_DEV_MEMLEAK"] = "1" if os.getenv("DEBUG_SUBD"): self.daemon.opts["dev-debugger"] = os.getenv("DEBUG_SUBD") if valgrind: self.daemon.env["LIGHTNINGD_DEV_NO_BACKTRACE"] = "1" + else: + # Under valgrind, scanning can access uninitialized mem. + self.daemon.env["LIGHTNINGD_DEV_MEMLEAK"] = "1" if not may_reconnect: self.daemon.opts["dev-no-reconnect"] = None