From 7b55d6cfe23c12521561b45abb639f8498d6e0ca Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 23 Sep 2020 11:07:04 +0930 Subject: [PATCH] common: enforce that we have collected all wally allocations. Signed-off-by: Rusty Russell --- common/daemon.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/common/daemon.c b/common/daemon.c index 4b76f9b65..c19bb86bf 100644 --- a/common/daemon.c +++ b/common/daemon.c @@ -81,11 +81,20 @@ void send_backtrace(const char *why) int daemon_poll(struct pollfd *fds, nfds_t nfds, int timeout) { const char *t; + char *wally_leak; t = taken_any(); if (t) errx(1, "Outstanding taken pointers: %s", t); + wally_leak = tal_first(wally_tal_ctx); + if (wally_leak) { + /* Trigger valgrind to tell us about this! */ + tal_free(wally_leak); + *wally_leak = 0; + errx(1, "Outstanding wally allocations"); + } + clean_tmpctx(); return poll(fds, nfds, timeout);