From 3ecf6b3528f4eff4b39090d0243c932a33cb3ef9 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 14 Jun 2019 13:20:07 +0930 Subject: [PATCH] lightningd: free htlc maps on exit. Direct leak of 16 byte(s) in 1 object(s) allocated from: #0 0x7ff02889063e in calloc (/lib/x86_64-linux-gnu/libasan.so.5+0x10c63e) #1 0x555ce2ad8d2e in htable_default_alloc ccan/ccan/htable/htable.c:19 #2 0x555ce2ad9698 in double_table ccan/ccan/htable/htable.c:226 #3 0x555ce2ad9b62 in htable_add_ ccan/ccan/htable/htable.c:331 #4 0x555ce2a638e4 in htlc_in_map_add lightningd/htlc_end.h:113 #5 0x555ce2a63beb in connect_htlc_in lightningd/htlc_end.c:39 #6 0x555ce2a85cbc in channel_added_their_htlc lightningd/peer_htlcs.c:1382 #7 0x555ce2a860e1 in peer_got_commitsig lightningd/peer_htlcs.c:1466 #8 0x555ce2a5db04 in channel_msg lightningd/channel_control.c:228 #9 0x555ce2a8d393 in sd_msg_read lightningd/subd.c:474 #10 0x555ce2ada157 in next_plan ccan/ccan/io/io.c:59 #11 0x555ce2adacd4 in do_plan ccan/ccan/io/io.c:407 #12 0x555ce2adad12 in io_ready ccan/ccan/io/io.c:417 #13 0x555ce2adcd67 in io_loop ccan/ccan/io/poll.c:445 #14 0x555ce2a67c66 in io_loop_with_timers lightningd/io_loop_with_timers.c:24 #15 0x555ce2a6e56b in main lightningd/lightningd.c:822 #16 0x7ff028242b6a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x26b6a) Signed-off-by: Rusty Russell --- lightningd/lightningd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lightningd/lightningd.c b/lightningd/lightningd.c index 61e4917c7824..9bee17ff31fb 100644 --- a/lightningd/lightningd.c +++ b/lightningd/lightningd.c @@ -851,6 +851,10 @@ int main(int argc, char *argv[]) free_unreleased_txs(ld->wallet); db_commit_transaction(ld->wallet->db); + /* Clean our our HTLC maps, since they use malloc. */ + htlc_in_map_clear(&ld->htlcs_in); + htlc_out_map_clear(&ld->htlcs_out); + remove(ld->pidfile); /* FIXME: pay can have children off tmpctx which unlink from