Skip to content

Commit 36d04c3

Browse files
authored
Merge pull request #4466 from tnull/2026-03-fix-utxo-debug-assert-race
Fix spurious `debug_assert` in UTXO gossip dedup check
2 parents 98393b3 + 40bc82c commit 36d04c3

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

lightning/src/routing/utxo.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -308,23 +308,27 @@ impl PendingChecks {
308308
// This may be called with the mutex held on a different UtxoMessages
309309
// struct, however in that case we have a global lockorder of new messages
310310
// -> old messages, which makes this safe.
311-
let pending_matches = match &pending_msgs
312-
.unsafe_well_ordered_double_lock_self()
313-
.channel_announce
314-
{
311+
let pending_state = pending_msgs.unsafe_well_ordered_double_lock_self();
312+
let pending_matches = match &pending_state.channel_announce {
315313
Some(ChannelAnnouncement::Full(pending_msg)) => {
316314
Some(pending_msg) == full_msg
317315
},
318316
Some(ChannelAnnouncement::Unsigned(pending_msg)) => pending_msg == msg,
319317
None => {
320-
// This shouldn't actually be reachable. We set the
321-
// `channel_announce` field under the same lock as setting the
322-
// channel map entry. Still, we can just treat it as
318+
// This can be reached if `resolve_single_future` has already
319+
// consumed `channel_announce` via `.take()` while the
320+
// `Arc<Mutex<UtxoMessages>>` is still alive (e.g. held on
321+
// the stack of `check_resolved_futures`). In that case,
322+
// `complete` should also have been taken. Treat it as
323323
// non-matching and let the new request fly.
324-
debug_assert!(false);
324+
debug_assert!(
325+
pending_state.complete.is_none(),
326+
"channel_announce is None but complete is still pending"
327+
);
325328
false
326329
},
327330
};
331+
drop(pending_state);
328332
if pending_matches {
329333
return Err(LightningError {
330334
err: "Channel announcement is already being checked".to_owned(),

0 commit comments

Comments
 (0)