Skip to content

Fix potential deadlock - #506

Merged
mxaddict merged 1 commit into
navcoin:masterfrom
aguycalled:fix-deadlock
Jun 10, 2019
Merged

Fix potential deadlock#506
mxaddict merged 1 commit into
navcoin:masterfrom
aguycalled:fix-deadlock

Conversation

@aguycalled

Copy link
Copy Markdown
Member

This PR fixes a potential deadlock moving IsColdStakingEnabled() out of CheckTransaction().

2019-06-04 20:36:10  (1) cs_main  wallet/wallet.cpp:1965
2019-06-04 20:36:10  (2) cs_wallet  wallet/wallet.cpp:1965
2019-06-04 20:36:10 Current lock order is:
2019-06-04 20:36:10  (2) pwallet->cs_wallet  wallet/walletdb.cpp:633
2019-06-04 20:36:10  (1) cs_main  ./main.cpp:4589

@mxaddict

mxaddict commented Jun 5, 2019

Copy link
Copy Markdown
Contributor

utACK

@red010b37
red010b37 self-requested a review June 5, 2019 10:04
@proletesseract

Copy link
Copy Markdown
Member

compiling and testing now.

@proletesseract proletesseract left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Compiles and runs on ubuntu 18.04. Test suite runs. Not entirely sure exactly how to test this specific change. Code looks fine. Can you perhaps just explain in a bit more detail what was wrong and what you did to fix it? If I understand correctly, having the cold staking check where it was before could cause a conflict in how the thread locking occurs resulting in this algorithm being unable to proceed?

@aguycalled

Copy link
Copy Markdown
Member Author

IsColdStakingEnabled() locked cs_main while CheckTransaction() locks cs_wallet, so every call to CheckTransaction() was locking in the order cs_wallet,cs_main conflicting with the lock order from wallet/wallet.cpp:1965 which runs in parallel in other thread

@mxaddict mxaddict left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested Ubuntu 18.04 ran node for 26 hours

@mxaddict
mxaddict merged commit de6e167 into navcoin:master Jun 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants