Skip to content

Commit 2dc0232

Browse files
committed
gossipd: fix false memleak positive in gossmap_manage
If there are pending channel announcements, they'll look like a leak unless we scan into the maps. ``` lightningd-2 2025-05-01T07:27:03.922Z **BROKEN** gossipd: MEMLEAK: 0x60d000000478 lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: label=gossipd/gossmap_manage.c:595:struct pending_cannounce lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: alloc: lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: /home/runner/work/lightning/lightning/ccan/ccan/tal/tal.c:488 (tal_alloc_) lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: /home/runner/work/lightning/lightning/gossipd/gossmap_manage.c:595 (gossmap_manage_channel_announcement) lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: /home/runner/work/lightning/lightning/gossipd/gossipd.c:205 (handle_recv_gossip) lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: /home/runner/work/lightning/lightning/gossipd/gossipd.c:300 (connectd_req) lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: /home/runner/work/lightning/lightning/common/daemon_conn.c:35 (handle_read) lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: /home/runner/work/lightning/lightning/ccan/ccan/io/io.c:60 (next_plan) lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: /home/runner/work/lightning/lightning/ccan/ccan/io/io.c:422 (do_plan) lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: /home/runner/work/lightning/lightning/ccan/ccan/io/io.c:439 (io_ready) lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: /home/runner/work/lightning/lightning/ccan/ccan/io/poll.c:455 (io_loop) lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: /home/runner/work/lightning/lightning/gossipd/gossipd.c:660 (main) lightningd-2 2025-05-01T07:27:03.923Z **BROKEN** gossipd: ../sysdeps/nptl/libc_start_call_main.h:58 (__libc_start_call_main) lightningd-2 2025-05-01T07:27:03.924Z **BROKEN** gossipd: ../csu/libc-start.c:392 (__libc_start_main_impl) lightningd-2 2025-05-01T07:27:03.924Z **BROKEN** gossipd: parents: lightningd-2 2025-05-01T07:27:03.924Z **BROKEN** gossipd: gossipd/gossmap_manage.c:475:struct gossmap_manage ``` Signed-off-by: Rusty Russell <[email protected]>
1 parent 1e2a6ed commit 2dc0232

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

gossipd/gossipd.c

+1
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ static void dev_gossip_memleak(struct daemon *daemon, const u8 *msg)
479479
memleak_scan_obj(memtable, daemon);
480480
memleak_scan_htable(memtable, &daemon->peers->raw);
481481
dev_seeker_memleak(memtable, daemon->seeker);
482+
gossmap_manage_memleak(memtable, daemon->gm);
482483

483484
found_leak = dump_memleak(memtable, memleak_status_broken, NULL);
484485
daemon_conn_send(daemon->master,

gossipd/gossmap_manage.c

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <common/daemon_conn.h>
77
#include <common/gossip_store.h>
88
#include <common/gossmap.h>
9+
#include <common/memleak.h>
910
#include <common/status.h>
1011
#include <common/timeout.h>
1112
#include <common/wire_error.h>
@@ -469,6 +470,13 @@ static bool setup_gossmap(struct gossmap_manage *gm,
469470
return true;
470471
}
471472

473+
void gossmap_manage_memleak(struct htable *memtable,
474+
const struct gossmap_manage *gm)
475+
{
476+
memleak_scan_uintmap(memtable, &gm->pending_ann_map.map);
477+
memleak_scan_uintmap(memtable, &gm->early_ann_map.map);
478+
}
479+
472480
struct gossmap_manage *gossmap_manage_new(const tal_t *ctx,
473481
struct daemon *daemon)
474482
{

gossipd/gossmap_manage.h

+3
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,7 @@ void gossmap_manage_tell_lightningd_locals(struct daemon *daemon,
111111
* The seeker uses this if we're at startup and want complete gossip.
112112
*/
113113
bool gossmap_manage_populated(const struct gossmap_manage *gm);
114+
115+
/* For memleak to see inside of maps */
116+
void gossmap_manage_memleak(struct htable *memtable, const struct gossmap_manage *gm);
114117
#endif /* LIGHTNING_GOSSIPD_GOSSMAP_MANAGE_H */

0 commit comments

Comments
 (0)