HomePhabricator

strengthen AssertLockNotHeld assertions

Tags
None
Subscribers
None
Tokens
"Doubloon" token, awarded by Unknown Object (User).

Description

strengthen AssertLockNotHeld assertions

Summary:
This changes AssertLockNotHeld so that it is annotated with the negative capability for the mutex it refers to. clang applies negative capabilities recursively, so this helps avoid forgetting to annotate functions.

Note that this can't reasonably be used for globals, because clang would require every function to be annotated with EXCLUSIVE_LOCKS_REQUIRED(!g_mutex) for each global mutex. At present, the only global mutexes that use AssertLockNotHeld are RecursiveMutex so we treat that as an exception in order to avoid having to add an excessive number of negative annotations.

This is a backport of core#25109

Notes:

  • the changes in versionbits.h are not relevant to us because we removed most of the BIP9 related code
  • we have two variants of Misbehaving to annotate because of D384
  • m_sock_mutex is still called cs_hSocket in our codebase because of a missing backport
  • it makes sens to annotate RelayProof for the same reason as RelayTransaction
  • ReceivedAvalancheProof needs to be annotated because it calls Misbehaving and RelayProof

Test Plan:
With clang and Debug
ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D14876

Details

Provenance
Anthony Towns <aj@erisian.com.au>Authored on Apr 20 2022, 06:47
PiRKCommitted on Nov 30 2023, 10:28
PiRKPushed on Nov 30 2023, 10:28
Reviewer
Restricted Project
Differential Revision
D14876: strengthen AssertLockNotHeld assertions
Parents
rABC46103b0bcf93: [alias-server] Implement chronik with backup connections
Branches
Unknown
Tags
Unknown