Fix spurious debug_assert in UTXO gossip dedup check#4466
Merged
TheBlueMatt merged 1 commit intolightningdevkit:mainfrom Mar 6, 2026
Merged
Fix spurious debug_assert in UTXO gossip dedup check#4466TheBlueMatt merged 1 commit intolightningdevkit:mainfrom
debug_assert in UTXO gossip dedup check#4466TheBlueMatt merged 1 commit intolightningdevkit:mainfrom
Conversation
`check_replace_previous_entry` hit `debug_assert!(false)` when `channel_announce` was `None` on a still-live `UtxoMessages`. The comment claimed this was unreachable because `channel_announce` is set under the same lock as the channel map entry. However, there is a legitimate race: 1. A channel announcement arrives, an async UTXO lookup starts, and `pending_channels[scid]` is set with a `Weak` to the `UtxoMessages`. 2. The lookup resolves. `resolve_single_future` takes both `channel_announce` and `complete` via `.take()`, but the `Arc<Mutex<UtxoMessages>>` is still alive on the stack of `check_resolved_futures`. 3. A duplicate announcement for the same SCID arrives during this window. `check_replace_previous_entry` upgrades the `Weak`, finds `channel_announce` is `None`, and hits the assert. Replace the unconditional `debug_assert!(false)` with a targeted check that `complete` has also been taken (confirming the future resolved), which would catch a genuinely unexpected state where `channel_announce` is `None` but `complete` is still pending. Co-Authored-By: HAL 9000
|
👋 Thanks for assigning @TheBlueMatt as a reviewer! |
TheBlueMatt
approved these changes
Mar 6, 2026
Collaborator
TheBlueMatt
left a comment
There was a problem hiding this comment.
Thanks. CI unrelated:
Well, this is embarrassing.
cargo-semver-checks had a problem and crashed. To help us diagnose the problem you can send us a crash report.
|
👋 The first review has been submitted! Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4439.
check_replace_previous_entryhitdebug_assert!(false)whenchannel_announcewasNoneon a still-liveUtxoMessages. The comment claimed this was unreachable becausechannel_announceis set under the same lock as the channel map entry. However, there is a legitimate race:pending_channels[scid]is set with aWeakto theUtxoMessages.resolve_single_futuretakes bothchannel_announceandcompletevia.take(), but theArc<Mutex<UtxoMessages>>is still alive on the stack ofcheck_resolved_futures.check_replace_previous_entryupgrades theWeak, findschannel_announceisNone, and hits the assert.Replace the unconditional
debug_assert!(false)with a targeted check thatcompletehas also been taken (confirming the future resolved), which would catch a genuinely unexpected state wherechannel_announceisNonebutcompleteis still pending.Co-Authored-By: HAL 9000