Skip to content
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

[Bug] Fix data race #2919

Merged
merged 1 commit into from
Mar 30, 2024
Merged

[Bug] Fix data race #2919

merged 1 commit into from
Mar 30, 2024

Conversation

panleone
Copy link

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 mutex cs_main that guards pcoinsTip.

This data race was causing the functional test wallet_basic.py to randomly fail: To see this I created two test branches where I ran wallet_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

@panleone panleone added the Bug label Mar 26, 2024
@panleone panleone added this to the 6.0.0 milestone Mar 26, 2024
@panleone panleone self-assigned this Mar 26, 2024
Copy link
Member

@Duddino Duddino left a comment

Choose a reason for hiding this comment

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

utACK 35c9b1e

Copy link
Member

@Liquid369 Liquid369 left a comment

Choose a reason for hiding this comment

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

tACK 35c9b1e

Copy link
Collaborator

@Fuzzbawls Fuzzbawls left a comment

Choose a reason for hiding this comment

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

ACK 35c9b1e

@Fuzzbawls Fuzzbawls merged commit 75ad914 into PIVX-Project:master Mar 30, 2024
21 checks passed
@panleone panleone deleted the data_race_fix branch March 30, 2024 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants