-
Notifications
You must be signed in to change notification settings - Fork 37.7k
index: prevent race by calling 'CustomInit' prior setting 'synced' flag #27720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The 'm_synced' flag enables 'BlockConnected' events to be processed by the index. If we set the flag before calling 'CustomInit', we could be dispatching a block connected event to an uninitialized index child class. e.g. BlockFilterIndex, initializes the next filter position inside 'CustomInit'. So, if `CustomInit` is not called prior receiving the block event, the index will use 'next_filter_position=0' which overwrites the first filter in disk.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK 3126454
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, ACK 3126454
ACK 3126454 |
…r setting 'synced' flag 3126454 index: prevent race by calling 'CustomInit' prior setting 'synced' flag (furszy) Pull request description: Decoupled from bitcoin#27607. Fixed a potential race condition in master (not possible so far) that could become an actual issue soon. Where the index's `CustomAppend` method could be called (from `BlockConnected`) before its `CustomInit` method, causing the index to try to update itself before it is initialized. This could happen because we set the index `m_synced` flag (which enables `BlockConnected` events) before calling to the child class init function (`CustomInit`). So, for example, the block filter index could process a block before initialize the next filter position field and end up overwriting the first stored filter. This race was introduced in bitcoin@bef4e40 from bitcoin#25494. ACKs for top commit: achow101: ACK 3126454 mzumsande: Code review ACK 3126454 TheCharlatan: Nice, ACK 3126454 Tree-SHA512: 7a53fed1d2035cb4c1f331d6ee9f92d499b6cbb618ea534c6440f5a45ff9b3ac4dcff5fb4b88937f45a0be249e3a9c6dc6c3ac77180f12ae25fc56856ba39735
Decoupled from #27607.
Fixed a potential race condition in master (not possible so far) that could become an actual issue soon.
Where the index's
CustomAppend
method could be called (fromBlockConnected
) before itsCustomInit
method, causing the index to try to update itself before it is initialized.This could happen because we set the index
m_synced
flag (which enablesBlockConnected
events)before calling to the child class init function (
CustomInit
). So, for example, the block filter index couldprocess a block before initialize the next filter position field and end up overwriting the first stored filter.
This race was introduced in bef4e40 from #25494.