Skip to content
Open
Changes from all commits
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
11 changes: 8 additions & 3 deletions p2p/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,17 @@ impl MessageHandler for Protocol {
);
return Err(Error::BadMessage);
}
if !self.state_sync_requested.load(Ordering::Relaxed) {
// Atomically claim the outstanding state-sync request so two
// concurrent archive messages cannot both observe "requested"
// and proceed (load+store race; see #3588).
if self
.state_sync_requested
.compare_exchange(true, false, Ordering::SeqCst, Ordering::Relaxed)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue #3588 raised a static analysis concern about another thread updating the flag between the load and store. The race described in this PR does not appear reachable, since archive responses from a peer are processed one at a time. Could we clarify which concrete interleaving this fixes? If it is a delayed response overlapping a newer request, this boolean still cannot tell them apart.

.is_err()
{
error!("handle_payload: txhashset archive received but from the wrong peer",);
return Err(Error::BadMessage);
}
// Update the sync state requested status
self.state_sync_requested.store(false, Ordering::Relaxed);

let start_time = Utc::now();
self.adapter
Expand Down
Loading