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.
Fix the data race in which a thread is trying to write
pcoinsTip.cacheSaplingAnchors
:CWallet::BlockConnected -> pcoinsTip->GetSaplingAnchorAt(...)
At the same time another thread is trying to read
pcoinsTip.cacheSaplingAnchors
:ActivateBestChain -> FlushStateToDisk -> pcoinsTip->DynamicMemoryUsage()
.The fix is trivial
CWallet::BlockConnected
was not locking the mutexcs_main
that guardspcoinsTip
.This data race was causing the functional test
wallet_basic.py
to randomly fail: To see this I created two test branches where I ranwallet_basic.py
50 times in parallel. One branch has this fix the other doesn't.The github action for the branch without this fix failed many times
https://github.com/panleone/PIVX/actions/runs/8428460478
The github action for the branch with this fixed always passed instead
https://github.com/panleone/PIVX/actions/runs/8428472901