-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Release LockData::dd_mutex
before calling *_detected
functions
#26781
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
base: master
Are you sure you want to change the base?
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/26781. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsNo conflicts as of last run. |
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 20647b8
There hasn't been much activity lately. What is the status here? Finding reviewers may take time. However, if the patch is no longer relevant, please close this pull request. If the author lost interest or time to work on this, please close it and mark it 'Up for grabs' with the label, so that it can be picked up in the future. |
cc @ryanofsky |
Both `double_lock_detected()` and `potential_deadlock_detected()` functions call `LogPrintf()` which in turn implies locking of the `Logger::m_cs` mutex. To avoid a deadlock the latter must not have the `Mutex` type. With this change the mentioned restriction has been lifted, and it is possible now to use our regular `Mutex` type for the `Logger::m_cs` mutex instead of a dedicated `StdMutex` type.
Rebased to refresh the CI. |
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 38f93fe
Do you mind having a look into this PR please? |
Sure, seems fine, but I don't see the benefit, if the logger is kept as-is? |
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.
Code review ACK 38f93fe. This seems like a good change, but I think it would be better if it had another commit getting rid of StdMutex/StdLockGuard. Otherwise nothing is really taking advantage of the change.
@@ -172,6 +172,7 @@ static void push_lock(MutexType* c, const CLockLocation& locklocation) | |||
// same thread as that results in an undefined behavior. | |||
auto lock_stack_copy = lock_stack; | |||
lock_stack.pop_back(); | |||
lock.unlock(); |
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.
In commit "Release LockData::dd_mutex
before calling *_detected
functions" (08cfe27)
Would be good to have a comment saying why this is necessary. If I understand correctly it could say something like // Release dd_mutex before calling double_lock_detected to avoid deadlocks, so no other lock is ever acquired after dd_mutex, and lock order is consistent.
@@ -182,9 +183,11 @@ static void push_lock(MutexType* c, const CLockLocation& locklocation) | |||
|
|||
const LockPair p2 = std::make_pair(c, i.first); | |||
if (lockdata.lockorders.count(p2)) { | |||
auto lock_stack_copy = lock_stack; | |||
auto lock_stack_current = lock_stack; |
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.
In commit "Release LockData::dd_mutex
before calling *_detected
functions" (08cfe27)
Previous name lock_stack_copy
seems like it explains the purpose for this variable better than lock_stack_current
. Also lock_stack_copy
is the name used above and it would be nicer if double_lock_detected and potential_deadlock_detected cases were handled consistently I think, unless I am missing something.
@hebasto Are you planning on addressing review feedback here?
I agree. The PR description sounded like this was going to be the ultimate change, but it does not appear to have actually been done. |
I re-reviewed this again and retain my ACK because IMO it is an improvement to I would be happy to review changing
well, fwiw, the description contains "not introducing that change here". |
🤔 There hasn't been much activity lately and the CI seems to be failing. If no one reviewed the current pull request by commit hash, a rebase can be considered. While the CI failure may be a false positive, the CI hasn't been running for some time, so there may be a real issue hiding as well. A rebase triggers the latest CI and makes sure that no silent merge conflicts have snuck in. |
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 38f93fe
(repeat my earlier comment, DrahtBot was confused)
🤔 There hasn't been much activity lately and the CI seems to be failing. If no one reviewed the current pull request by commit hash, a rebase can be considered. While the CI failure may be a false positive, the CI hasn't been running for some time, so there may be a real issue hiding as well. A rebase triggers the latest CI and makes sure that no silent merge conflicts have snuck in. |
Both
double_lock_detected()
andpotential_deadlock_detected()
functions callLogPrintf()
which in turn implies locking of theLogger::m_cs
mutex. To avoid a deadlock, the latter must not have theMutex
type (see #16112).With this PR the mentioned restriction has been lifted, and it is possible now to use our regular
Mutex
type for theLogger::m_cs
mutex instead of a dedicatedStdMutex
type (not introducing that change here, as its diff is much bigger than a few lines, and the currently proposed diff seems valuable by itself).Note for reviewers: Make sure the code is configured and built with
CPPFLAGS=-DDEBUG_LOCKORDER
.