Merge bitcoin/bitcoin#34813: threads: qa: Add lock order annotation for TxMempool::cs

9085dee476d21daab786e88848597c755beecee4 qa: Add lock order annotation for TxMempool::cs (David Gumberg)

Pull request description:

  I added this to see if static analysis would catch any lock order inversions while investigating #34731, it did not catch any but it is a worthwhile defense against statically-analyzable inversions of `cs_main->TxMempool::cs`.

ACKs for top commit:
  sedited:
    tested ACK 9085dee476d21daab786e88848597c755beecee4
  hebasto:
    ACK 9085dee476d21daab786e88848597c755beecee4.
  w0xlt:
    ACK 9085dee476d21daab786e88848597c755beecee4

Tree-SHA512: 498605362e7b197b7643a3f9ffd04589bc9b245aca1d245d289efa145906248c1a72f9fbf4835a9378aabe170b747dc0cc033105915a2bf7a9989de368710c02
This commit is contained in:
merge-script 2026-03-13 00:02:21 +00:00
commit 5f75d90c38
No known key found for this signature in database
GPG Key ID: 2EEB9F5CC09526C1

View File

@ -257,7 +257,7 @@ public:
* changing the chain tip. It's necessary to keep both mutexes locked until
* the mempool is consistent with the new chain tip and fully populated.
*/
mutable RecursiveMutex cs;
mutable RecursiveMutex cs ACQUIRED_AFTER(::cs_main);
std::unique_ptr<TxGraph> m_txgraph GUARDED_BY(cs);
mutable std::unique_ptr<TxGraph::BlockBuilder> m_builder GUARDED_BY(cs);
indexed_transaction_set mapTx GUARDED_BY(cs);