Skip to content

Commit 04e16b3

Browse files
committed
log: block reporting on minor memleak.
Exception: Node /tmp/lightning-t5gxc6gs/test_closing_different_fees/lightning-2/ has memory leaks: [{'value': '0x55caa0a0b8d0', 'label': 'ccan/ccan/tal/str/str.c:90:char[]', 'backtrace': ['ccan/ccan/tal/tal.c:467 (tal_alloc_)', 'ccan/ccan/tal/tal.c:496 (tal_alloc_arr_)', 'ccan/ccan/tal/str/str.c:90 (tal_vfmt)', 'lightningd/log.c:131 (new_log)', 'lightningd/subd.c:632 (new_subd)', 'lightningd/subd.c:686 (new_peer_subd)', 'lightningd/peer_control.c:2487 (peer_accept_channel)', 'lightningd/peer_control.c:674 (peer_sent_nongossip)', 'lightningd/gossip_control.c:55 (peer_nongossip)', 'lightningd/gossip_control.c:142 (gossip_msg)', 'lightningd/subd.c:477 (sd_msg_read)', 'lightningd/subd.c:319 (read_fds)', 'ccan/ccan/io/io.c:59 (next_plan)', 'ccan/ccan/io/io.c:387 (do_plan)', 'ccan/ccan/io/io.c:397 (io_ready)', 'ccan/ccan/io/poll.c:305 (io_loop)', 'lightningd/lightningd.c:347 (main)', '(null):0 ((null))', '(null):0 ((null))', '(null):0 ((null))'], 'parents': ['lightningd/log.c:103:struct log_book', 'lightningd/lightningd.c:43:struct lightningd']}] Technically, true, but we save more memory by sharing the prefix pointer than we lose by leaking it. However, we'd ideally refcount so it's freed if the log is freed and all the entries using it are pruned from the log book. Signed-off-by: Rusty Russell <[email protected]>
1 parent 402d27d commit 04e16b3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lightningd/log.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ new_log(const tal_t *ctx, struct log_book *record, const char *fmt, ...)
128128
log->lr = record;
129129
va_start(ap, fmt);
130130
/* log->lr owns this, since its entries keep a pointer to it. */
131-
log->prefix = tal_vfmt(log->lr, fmt, ap);
131+
/* FIXME: Refcount this! */
132+
log->prefix = notleak(tal_vfmt(log->lr, fmt, ap));
132133
va_end(ap);
133134

134135
return log;

0 commit comments

Comments
 (0)