From 77e3df0a29a3a70bace01118b8a44ac4307697df Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Fri, 14 Feb 2020 10:42:28 +1030 Subject: [PATCH] gossipd: remove assert which can trigger. We can actually fail to find a shorter route, but it's a fairly obscure case. Fixes: #3517 Signed-off-by: Rusty Russell --- gossipd/routing.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gossipd/routing.c b/gossipd/routing.c index 77e70737b..69f3ac6dc 100644 --- a/gossipd/routing.c +++ b/gossipd/routing.c @@ -1217,10 +1217,19 @@ find_shorter_route(const tal_t *ctx, struct routing_state *rstate, unvisited, shortest_cost_function); dijkstra_cleanup(unvisited); - /* This must succeed, since we found a route before */ + /* This will usually succeed, since we found a route before; however + * it's possible that it fails in corner cases. Consider that the reduced + * riskfactor may make us select a more fee-expensive route, which then + * makes us unable to complete the route due to htlc_max restrictions. */ short_route = build_route(ctx, rstate, dst, src, me, riskfactor, 1, fuzz, base_seed, fee); - assert(short_route); + if (!short_route) { + status_info("Could't find short enough route %s->%s", + type_to_string(tmpctx, struct node_id, &dst->id), + type_to_string(tmpctx, struct node_id, &src->id)); + goto out; + } + if (!amount_msat_sub(&short_cost, dst->dijkstra.total, src->dijkstra.total)) goto bad_total;