Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renepay simpler routetracking #7357

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
renepay: fix double free of tal object
routefail object allocation was linked to route,
we had a crash of the plugin with the following error:

0x561f424fc07a send_backtrace
	common/daemon.c:33
0x561f424fc102 crashdump
	common/daemon.c:75
0x7f5b0e7dc04f ???
	???:0
0x7f5b0e82ae2c ???
	???:0
0x7f5b0e7dbfb1 ???
	???:0
0x7f5b0e7c6471 ???
	???:0
0x561f4252581f call_error
	ccan/ccan/tal/tal.c:95
0x561f425258c8 check_bounds
	ccan/ccan/tal/tal.c:169
0x561f425258f9 to_tal_hdr
	ccan/ccan/tal/tal.c:179
0x561f42526283 tal_free
	ccan/ccan/tal/tal.c:525
0x561f424e5379 routefail_end
	plugins/renepay/routefail.c:52
0x561f424e557b handle_failure
	plugins/renepay/routefail.c:431

apparently there was a race condition for which the route was first
freed before we arrived to routefail_end where we manually free
routefail. I don't see how this could have happened, but anyways
this subtle bug can be avoided by linking the routefail to the payment.

Signed-off-by: Lagrang3 <lagrang3@protonmail.com>
  • Loading branch information
Lagrang3 committed Jun 11, 2024
commit c9343fcb8059e21c6fd7ecb5e937dbaf6b32b867
7 changes: 4 additions & 3 deletions plugins/renepay/routefail.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ struct command_result *routefail_start(const tal_t *ctx, struct route *route,
return update_gossip(r);
}

static struct command_result *routefail_end(struct routefail *r)
static struct command_result *routefail_end(struct routefail *r TAKES)
{
/* Notify the tracker that route has failed and routefail have completed
* handling all possible errors cases. */
struct command *cmd = r->cmd;
route_failure_register(r->payment->routetracker, r->route);
tal_free(r);
if (taken(r))
r = tal_steal(tmpctx, r);
return notification_handled(cmd);
}

Expand Down Expand Up @@ -428,5 +429,5 @@ static struct command_result *handle_failure(struct routefail *r)

break;
}
return routefail_end(r);
return routefail_end(take(r));
}
2 changes: 1 addition & 1 deletion plugins/renepay/routetracker.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ struct command_result *notification_sendpay_failure(struct command *cmd,

/* we do some error processing steps before calling
* route_failure_register. */
return routefail_start(route, route, cmd);
return routefail_start(payment, route, cmd);
}

struct command_result *notification_sendpay_success(struct command *cmd,
Expand Down
Loading