-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vochain/state: fix a data race in UpdateSIKRoots
UpdateSIKRoots uses State.NoState with withTxLock=false, as it grabs the State.tx lock itself, so NoState grabbing the same lock for reads and writes would cause deadlocks. However, UpdateSIKRoots only grabbed a read lock, and towards the end of its body it made a call to NoState.Set, which is a write operation that needs the write lock to be held. First, fix UpdateSIKRoots so it holds a write lock. Second, tweak NoState so that it loudly complains as soon as it can if it spots that reads or writes are happening without the mutex being properly locked at the right level. Note that for writes we only do this on the first call to Set or Delete, as some NoState callers only ever call read-only methods like Get. Hopefully these panic assertions will mean we catch future races much sooner; at least, without the UpdateSIKRoots fix, the new assertions make multiple of our tests panic every time. Fixes #1209.
- Loading branch information
Showing
3 changed files
with
22 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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