bitcoin icon indicating copy to clipboard operation
bitcoin copied to clipboard

Release `LockData::dd_mutex` before calling `*_detected` functions

Open hebasto opened this issue 2 years ago • 8 comments

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 (see https://github.com/bitcoin/bitcoin/pull/16112).

With this PR 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 (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.

hebasto avatar Dec 31 '22 15:12 hebasto

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage

For detailed information about the code coverage, see the test coverage report.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK ryanofsky
Concept ACK vasild

If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

DrahtBot avatar Dec 31 '22 15:12 DrahtBot

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.

DrahtBot avatar Aug 08 '23 17:08 DrahtBot

cc @ryanofsky

hebasto avatar Aug 08 '23 19:08 hebasto

Rebased to refresh the CI.

hebasto avatar Feb 12 '24 14:02 hebasto

@maflcko @ryanofsky

Do you mind having a look into this PR please?

hebasto avatar Mar 08 '24 10:03 hebasto

Sure, seems fine, but I don't see the benefit, if the logger is kept as-is?

maflcko avatar Mar 11 '24 13:03 maflcko

@hebasto Are you planning on addressing review feedback here?


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.

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.

achow101 avatar Jun 17 '24 21:06 achow101

I re-reviewed this again and retain my ACK because IMO it is an improvement to master even without further changes because it reduces the scope where the mutex is held. I don't see the fact that it can go further as a blocker for this.

I would be happy to review changing StdMutex m_cs to Mutex m_cs here or in another PR.

The PR description sounded like this was going to be the ultimate change

well, fwiw, the description contains "not introducing that change here".

vasild avatar Jun 21 '24 08:06 vasild