mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
memleak: make sure we catch children which are also "notleak".
By not recursing into "notleak" children, we could miss other "notleak" pointers: ``` 2022-03-15T05:25:33.9759500Z lightningd-1: 2022-03-15T05:00:15.998Z **BROKEN** connectd: MEMLEAK: 0x55b29c3d0cc8 2022-03-15T05:25:33.9759901Z lightningd-1: 2022-03-15T05:00:16.003Z **BROKEN** connectd: label=common/timeout.c:22:struct oneshot **NOTLEAK** 2022-03-15T05:25:33.9760195Z lightningd-1: 2022-03-15T05:00:16.003Z **BROKEN** connectd: backtrace: 2022-03-15T05:25:33.9760555Z lightningd-1: 2022-03-15T05:00:16.003Z **BROKEN** connectd: ccan/ccan/tal/tal.c:442 (tal_alloc_) 2022-03-15T05:25:33.9760905Z lightningd-1: 2022-03-15T05:00:16.003Z **BROKEN** connectd: common/timeout.c:22 (new_reltimer_) 2022-03-15T05:25:33.9761272Z lightningd-1: 2022-03-15T05:00:16.003Z **BROKEN** connectd: connectd/multiplex.c:558 (set_closing_timer) 2022-03-15T05:25:33.9761647Z lightningd-1: 2022-03-15T05:00:16.003Z **BROKEN** connectd: connectd/multiplex.c:586 (write_to_peer) 2022-03-15T05:25:33.9761986Z lightningd-1: 2022-03-15T05:00:16.003Z **BROKEN** connectd: ccan/ccan/io/io.c:59 (next_plan) 2022-03-15T05:25:33.9762335Z lightningd-1: 2022-03-15T05:00:16.004Z **BROKEN** connectd: ccan/ccan/io/io.c:435 (io_do_always) 2022-03-15T05:25:33.9762692Z lightningd-1: 2022-03-15T05:00:16.004Z **BROKEN** connectd: ccan/ccan/io/poll.c:304 (handle_always) 2022-03-15T05:25:33.9763035Z lightningd-1: 2022-03-15T05:00:16.004Z **BROKEN** connectd: ccan/ccan/io/poll.c:385 (io_loop) 2022-03-15T05:25:33.9763376Z lightningd-1: 2022-03-15T05:00:16.004Z **BROKEN** connectd: connectd/connectd.c:2131 (main) 2022-03-15T05:25:33.9763645Z lightningd-1: 2022-03-15T05:00:16.004Z **BROKEN** connectd: parents: 2022-03-15T05:25:33.9764020Z lightningd-1: 2022-03-15T05:00:16.004Z **BROKEN** connectd: ccan/ccan/io/io.c:91:struct io_conn **NOTLEAK** 2022-03-15T05:25:33.9764471Z lightningd-1: 2022-03-15T05:00:16.004Z **BROKEN** connectd: connectd/connectd.c:2104:struct daemon ``` Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -267,21 +267,25 @@ static void call_memleak_helpers(struct htable *memtable, const tal_t *p)
|
|||||||
for (i = tal_first(p); i; i = tal_next(i)) {
|
for (i = tal_first(p); i; i = tal_next(i)) {
|
||||||
const char *name = tal_name(i);
|
const char *name = tal_name(i);
|
||||||
|
|
||||||
if (name && strends(name, "struct memleak_helper")) {
|
if (name) {
|
||||||
const struct memleak_helper *mh = i;
|
if (strends(name, "struct memleak_helper")) {
|
||||||
mh->cb(memtable, p);
|
const struct memleak_helper *mh = i;
|
||||||
} else if (name && strends(name, " **NOTLEAK**")) {
|
mh->cb(memtable, p);
|
||||||
pointer_referenced(memtable, i);
|
} else if (strends(name, " **NOTLEAK**")
|
||||||
memleak_remove_region(memtable, i, tal_bytelen(i));
|
|| strends(name, "_notleak")) {
|
||||||
} else if (name && strends(name, " **NOTLEAK_IGNORE_CHILDREN**")) {
|
pointer_referenced(memtable, i);
|
||||||
remove_with_children(memtable, i);
|
memleak_remove_region(memtable, i,
|
||||||
memleak_remove_region(memtable, i, tal_bytelen(i));
|
tal_bytelen(i));
|
||||||
} else if (name && strends(name, "_notleak")) {
|
} else if (strends(name,
|
||||||
pointer_referenced(memtable, i);
|
" **NOTLEAK_IGNORE_CHILDREN**")) {
|
||||||
call_memleak_helpers(memtable, i);
|
remove_with_children(memtable, i);
|
||||||
} else {
|
memleak_remove_region(memtable, i,
|
||||||
call_memleak_helpers(memtable, i);
|
tal_bytelen(i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Recurse down looking for "notleak" children */
|
||||||
|
call_memleak_helpers(memtable, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user