From 1751f77edf1de9b0bd3985eeb94155172c415ad1 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 7 Mar 2023 18:06:12 +0000 Subject: [PATCH] Avoid `poll`ing completed futures in the `background-processor` `poll`ing completed futures invokes undefined behavior in Rust (panics, etc, obviously not memory corruption as its not unsafe). Sadly, in our futures-based version of `lightning-background-processor` we have one case where we can `poll` a completed future - if the timer for the network graph prune + persist completes without a network graph to prune + persist we'll happily poll the same future over and over again, likely panicing in user code. --- lightning-background-processor/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lightning-background-processor/src/lib.rs b/lightning-background-processor/src/lib.rs index a6de0a62f..d5b6d3f2c 100644 --- a/lightning-background-processor/src/lib.rs +++ b/lightning-background-processor/src/lib.rs @@ -349,9 +349,9 @@ macro_rules! define_run_body { log_error!($logger, "Error: Failed to persist network graph, check your disk and permissions {}", e) } - last_prune_call = $get_timer(NETWORK_PRUNE_TIMER); have_pruned = true; } + last_prune_call = $get_timer(NETWORK_PRUNE_TIMER); } if $timer_elapsed(&mut last_scorer_persist_call, SCORER_PERSIST_TIMER) { -- 2.39.5