-
Notifications
You must be signed in to change notification settings - Fork 64
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
Fix: Dandelion mutex LOCK usages #84
Fix: Dandelion mutex LOCK usages #84
Conversation
Will fire this up now with |
@@ -2645,6 +2645,7 @@ bool CChainState::ActivateBestChainStep(BlockValidationState& state, CBlockIndex | |||
{ | |||
AssertLockHeld(cs_main); | |||
if (m_mempool) AssertLockHeld(m_mempool->cs); | |||
if (m_stempool) AssertLockHeld(m_stempool->cs); |
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.
not sure if this is needed, 'MaybeUpdateMempoolForReorg' contains an assert for stempool already
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.
Yeah agree with @barrystyle here, seems redundant.
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.
Are you able to remove the redundant asserts?
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.
I see where you are coming from. The signature of MaybeUpdateMempoolForReorg
requires callers to assert that locks are held already. Super useful for static analysis.
This is also the reason the Bitcoin Developers added a check for the mempool mutex in the first place (L2647) although it is checked again in MaybeUpdateMempoolForReorg
.
Was any of this backed with 'deadlocked thread' output from debug? |
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.
ACK. Client compiles, runs & sends tx's fine.
Side note: Still seeing the "Blockpolicy error mempool tx *** already being tracked" quite often.
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.
cACK. I would like to get @barrystyle 's questions answered before we merge.
cACK for now. |
This is seriously an issue we have to fix. @barrystyle Maybe you can take a look into this? |
Would love to merge this if no one is opposed to that |
This PR fixes the
stempool
mutex usage inActivateBestChain()
.In some places the mutex wasn't acquired which could lead to race conditions, so it was added where needed.
And in some locations the mutex wasn't required where
EXCLUSIVE_LOCKS_REQUIRED
as modified accordingly.