Skip to content

eth/downloader: fix possible data race caused by inconsistent field protection#20650

Closed
Chain-Fox wants to merge 1 commit intoethereum:masterfrom
Chain-Fox:bug-5-11-inconsistent-field-protection
Closed

eth/downloader: fix possible data race caused by inconsistent field protection#20650
Chain-Fox wants to merge 1 commit intoethereum:masterfrom
Chain-Fox:bug-5-11-inconsistent-field-protection

Conversation

@Chain-Fox
Copy link
Copy Markdown
Contributor

Fixed inconsistency and also potential data race in eth/downloader/peer.go and eth/downloader/queue.go:
e.g. In eth/downloader/queue.go:
q.receiptPendPool is read/written 10 times; 9 out of 10 times it is protected by q.lock.Lock(); 1 out of 10 times it is read without a Lock, which is in func CancelReceipts() on L579.
A data race may happen when CancelReceipts() and other func like Revoke() are called in parallel.
The fix is to move lock from func cancel() to its caller CancelReceipts().
The other bugs and fixes are similar.

@Chain-Fox
Copy link
Copy Markdown
Contributor Author

They are FP because the lock inside setIdle() has already protected the write conducted on p.headerThroughput and p.headerIdle. I will close this PR.

@Chain-Fox Chain-Fox closed this Feb 16, 2020
@Chain-Fox
Copy link
Copy Markdown
Contributor Author

Chain-Fox commented Feb 19, 2020

eth/downloader/queue.go is not FP. So I will open a new PR and remove the unnecessary patch in eth/downloader/peer.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant