mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
lightningd: mark subd->conn notleak() properly in transition.
Since subd is temporarily unreferenced, and our leak detection goes up to the highest unreferenced parent, it complains about openingd->conn. The correct fix is to catch this where we detach the subd: ``` DEBUG:root:{ "id": 1, "result": { "leaks": [ { "value": "0x556e0445d8f8", "label": "ccan/ccan/io/io.c:91:struct io_conn", "backtrace": [ "ccan/ccan/tal/tal.c:442 (tal_alloc_)", "ccan/ccan/io/io.c:91 (io_new_conn_)", "lightningd/subd.c:774 (new_subd)", "lightningd/subd.c:828 (new_channel_subd_)", "lightningd/opening_control.c:872 (peer_start_openingd)", "lightningd/peer_control.c:1311 (peer_active)", "lightningd/connect_control.c:458 (connectd_msg)", "lightningd/subd.c:557 (sd_msg_read)", "lightningd/subd.c:357 (read_fds)", "ccan/ccan/io/io.c:59 (next_plan)", "ccan/ccan/io/io.c:407 (do_plan)", "ccan/ccan/io/io.c:417 (io_ready)", "ccan/ccan/io/poll.c:453 (io_loop)", "lightningd/io_loop_with_timers.c:22 (io_loop_with_timers)", "lightningd/lightningd.c:1182 (main)", "../csu/libc-start.c:308 (__libc_start_main)" ], "parents": [ "lightningd/lightningd.c:107:struct lightningd" ] } ] } } ``` Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
6aec374674
commit
4633085ffd
@ -570,6 +570,12 @@ static void openingd_failed(struct subd *openingd, const u8 *msg,
|
|||||||
{
|
{
|
||||||
char *desc;
|
char *desc;
|
||||||
|
|
||||||
|
/* Since we're detaching from uc, we'll be unreferenced until
|
||||||
|
* our imminent exit (as will our parent, openingd->conn). */
|
||||||
|
notleak(openingd);
|
||||||
|
/* openingd->conn is set to NULL temporarily for this call, so: */
|
||||||
|
notleak(tal_parent(openingd));
|
||||||
|
|
||||||
if (!fromwire_openingd_failed(msg, msg, &desc)) {
|
if (!fromwire_openingd_failed(msg, msg, &desc)) {
|
||||||
log_broken(uc->log,
|
log_broken(uc->log,
|
||||||
"bad OPENINGD_FAILED %s",
|
"bad OPENINGD_FAILED %s",
|
||||||
@ -683,8 +689,6 @@ openchannel_hook_final(struct openchannel_hook_payload *payload STEALS)
|
|||||||
} else
|
} else
|
||||||
upfront_shutdown_script_wallet_index = NULL;
|
upfront_shutdown_script_wallet_index = NULL;
|
||||||
|
|
||||||
/* In case peer goes away right now, mark openingd notleak() */
|
|
||||||
notleak(openingd);
|
|
||||||
subd_send_msg(openingd,
|
subd_send_msg(openingd,
|
||||||
take(towire_openingd_got_offer_reply(NULL, errmsg,
|
take(towire_openingd_got_offer_reply(NULL, errmsg,
|
||||||
our_upfront_shutdown_script,
|
our_upfront_shutdown_script,
|
||||||
|
Loading…
Reference in New Issue
Block a user