Skip to content

Commit aa3200d

Browse files
author
MacroFake
committed
Merge bitcoin/bitcoin#25109: Strengthen AssertLockNotHeld assertions
436ce02 sync.h: strengthen AssertLockNotHeld assertion (Anthony Towns) 7d73f58 Increase threadsafety annotation coverage (Anthony Towns) Pull request description: 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. ACKs for top commit: vasild: ACK 436ce02 MarcoFalke: review ACK 436ce02 🌺 Tree-SHA512: 5f16d098790a36b5277324d5ee89cdc87033c19b11c7943c2f630a41c2e3998eb39d356a763e857f4d8fefb6c0c02291f720bb6769bcbdf5e2cd765bf266ab8c
2 parents dc0ee57 + 436ce02 commit aa3200d

13 files changed

+108
-89
lines changed

src/checkqueue.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class CCheckQueue
6666
bool m_request_stop GUARDED_BY(m_mutex){false};
6767

6868
/** Internal function that does bulk of the verification work. */
69-
bool Loop(bool fMaster)
69+
bool Loop(bool fMaster) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
7070
{
7171
std::condition_variable& cond = fMaster ? m_master_cv : m_worker_cv;
7272
std::vector<T> vChecks;
@@ -140,7 +140,7 @@ class CCheckQueue
140140
}
141141

142142
//! Create a pool of new worker threads.
143-
void StartWorkerThreads(const int threads_num)
143+
void StartWorkerThreads(const int threads_num) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
144144
{
145145
{
146146
LOCK(m_mutex);
@@ -159,13 +159,13 @@ class CCheckQueue
159159
}
160160

161161
//! Wait until execution finishes, and return whether all evaluations were successful.
162-
bool Wait()
162+
bool Wait() EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
163163
{
164164
return Loop(true /* master thread */);
165165
}
166166

167167
//! Add a batch of checks to the queue
168-
void Add(std::vector<T>& vChecks)
168+
void Add(std::vector<T>& vChecks) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
169169
{
170170
if (vChecks.empty()) {
171171
return;
@@ -188,7 +188,7 @@ class CCheckQueue
188188
}
189189

190190
//! Stop all of the worker threads.
191-
void StopWorkerThreads()
191+
void StopWorkerThreads() EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
192192
{
193193
WITH_LOCK(m_mutex, m_request_stop = true);
194194
m_worker_cv.notify_all();

src/httpserver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class WorkQueue
8787
{
8888
}
8989
/** Enqueue a work item */
90-
bool Enqueue(WorkItem* item)
90+
bool Enqueue(WorkItem* item) EXCLUSIVE_LOCKS_REQUIRED(!cs)
9191
{
9292
LOCK(cs);
9393
if (!running || queue.size() >= maxDepth) {
@@ -98,7 +98,7 @@ class WorkQueue
9898
return true;
9999
}
100100
/** Thread function */
101-
void Run()
101+
void Run() EXCLUSIVE_LOCKS_REQUIRED(!cs)
102102
{
103103
while (true) {
104104
std::unique_ptr<WorkItem> i;
@@ -115,7 +115,7 @@ class WorkQueue
115115
}
116116
}
117117
/** Interrupt and exit loops */
118-
void Interrupt()
118+
void Interrupt() EXCLUSIVE_LOCKS_REQUIRED(!cs)
119119
{
120120
LOCK(cs);
121121
running = false;

src/i2p.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class Session
8484
* to the listening socket and address.
8585
* @return true on success
8686
*/
87-
bool Listen(Connection& conn);
87+
bool Listen(Connection& conn) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex);
8888

8989
/**
9090
* Wait for and accept a new incoming connection.
@@ -103,7 +103,7 @@ class Session
103103
* it is set to `false`. Only set if `false` is returned.
104104
* @return true on success
105105
*/
106-
bool Connect(const CService& to, Connection& conn, bool& proxy_error);
106+
bool Connect(const CService& to, Connection& conn, bool& proxy_error) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex);
107107

108108
private:
109109
/**
@@ -172,7 +172,7 @@ class Session
172172
/**
173173
* Check the control socket for errors and possibly disconnect.
174174
*/
175-
void CheckControlSock();
175+
void CheckControlSock() EXCLUSIVE_LOCKS_REQUIRED(!m_mutex);
176176

177177
/**
178178
* Generate a new destination with the SAM proxy and set `m_private_key` to it.

src/index/blockfilterindex.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class BlockFilterIndex final : public BaseIndex
6464
bool LookupFilter(const CBlockIndex* block_index, BlockFilter& filter_out) const;
6565

6666
/** Get a single filter header by block. */
67-
bool LookupFilterHeader(const CBlockIndex* block_index, uint256& header_out);
67+
bool LookupFilterHeader(const CBlockIndex* block_index, uint256& header_out) EXCLUSIVE_LOCKS_REQUIRED(!m_cs_headers_cache);
6868

6969
/** Get a range of filters between two heights on a chain. */
7070
bool LookupFilterRange(int start_height, const CBlockIndex* stop_index,

src/net.h

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ class CNode
612612
* @return True if the peer should stay connected,
613613
* False if the peer should be disconnected from.
614614
*/
615-
bool ReceiveMsgBytes(Span<const uint8_t> msg_bytes, bool& complete);
615+
bool ReceiveMsgBytes(Span<const uint8_t> msg_bytes, bool& complete) EXCLUSIVE_LOCKS_REQUIRED(!cs_vRecv);
616616

617617
void SetCommonVersion(int greatest_common_version)
618618
{
@@ -624,9 +624,9 @@ class CNode
624624
return m_greatest_common_version;
625625
}
626626

627-
CService GetAddrLocal() const LOCKS_EXCLUDED(m_addr_local_mutex);
627+
CService GetAddrLocal() const EXCLUSIVE_LOCKS_REQUIRED(!m_addr_local_mutex);
628628
//! May not be called more than once
629-
void SetAddrLocal(const CService& addrLocalIn) LOCKS_EXCLUDED(m_addr_local_mutex);
629+
void SetAddrLocal(const CService& addrLocalIn) EXCLUSIVE_LOCKS_REQUIRED(!m_addr_local_mutex);
630630

631631
CNode* AddRef()
632632
{
@@ -639,9 +639,9 @@ class CNode
639639
nRefCount--;
640640
}
641641

642-
void CloseSocketDisconnect();
642+
void CloseSocketDisconnect() EXCLUSIVE_LOCKS_REQUIRED(!m_sock_mutex);
643643

644-
void CopyStats(CNodeStats& stats);
644+
void CopyStats(CNodeStats& stats) EXCLUSIVE_LOCKS_REQUIRED(!m_subver_mutex, !m_addr_local_mutex, !cs_vSend, !cs_vRecv);
645645

646646
ServiceFlags GetLocalServices() const
647647
{
@@ -760,7 +760,7 @@ class CConnman
760760
bool m_i2p_accept_incoming;
761761
};
762762

763-
void Init(const Options& connOptions) EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex)
763+
void Init(const Options& connOptions) EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex, !m_total_bytes_sent_mutex)
764764
{
765765
AssertLockNotHeld(m_total_bytes_sent_mutex);
766766

@@ -794,7 +794,8 @@ class CConnman
794794
bool network_active = true);
795795

796796
~CConnman();
797-
bool Start(CScheduler& scheduler, const Options& options) EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex);
797+
798+
bool Start(CScheduler& scheduler, const Options& options) EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex, !m_added_nodes_mutex, !m_addr_fetches_mutex, !mutexMsgProc);
798799

799800
void StopThreads();
800801
void StopNodes();
@@ -804,7 +805,7 @@ class CConnman
804805
StopNodes();
805806
};
806807

807-
void Interrupt();
808+
void Interrupt() EXCLUSIVE_LOCKS_REQUIRED(!mutexMsgProc);
808809
bool GetNetworkActive() const { return fNetworkActive; };
809810
bool GetUseAddrmanOutgoing() const { return m_use_addrman_outgoing; };
810811
void SetNetworkActive(bool active);
@@ -868,9 +869,9 @@ class CConnman
868869
// Count the number of block-relay-only peers we have over our limit.
869870
int GetExtraBlockRelayCount() const;
870871

871-
bool AddNode(const std::string& node);
872-
bool RemoveAddedNode(const std::string& node);
873-
std::vector<AddedNodeInfo> GetAddedNodeInfo() const;
872+
bool AddNode(const std::string& node) EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex);
873+
bool RemoveAddedNode(const std::string& node) EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex);
874+
std::vector<AddedNodeInfo> GetAddedNodeInfo() const EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex);
874875

875876
/**
876877
* Attempts to open a connection. Currently only used from tests.
@@ -923,7 +924,7 @@ class CConnman
923924

924925
unsigned int GetReceiveFloodSize() const;
925926

926-
void WakeMessageHandler();
927+
void WakeMessageHandler() EXCLUSIVE_LOCKS_REQUIRED(!mutexMsgProc);
927928

928929
/** Return true if we should disconnect the peer for failing an inactivity check. */
929930
bool ShouldRunInactivityChecks(const CNode& node, std::chrono::seconds now) const;
@@ -950,11 +951,11 @@ class CConnman
950951
bool Bind(const CService& addr, unsigned int flags, NetPermissionFlags permissions);
951952
bool InitBinds(const Options& options);
952953

953-
void ThreadOpenAddedConnections();
954-
void AddAddrFetch(const std::string& strDest);
955-
void ProcessAddrFetch();
956-
void ThreadOpenConnections(std::vector<std::string> connect);
957-
void ThreadMessageHandler();
954+
void ThreadOpenAddedConnections() EXCLUSIVE_LOCKS_REQUIRED(!m_added_nodes_mutex);
955+
void AddAddrFetch(const std::string& strDest) EXCLUSIVE_LOCKS_REQUIRED(!m_addr_fetches_mutex);
956+
void ProcessAddrFetch() EXCLUSIVE_LOCKS_REQUIRED(!m_addr_fetches_mutex);
957+
void ThreadOpenConnections(std::vector<std::string> connect) EXCLUSIVE_LOCKS_REQUIRED(!m_addr_fetches_mutex, !m_added_nodes_mutex, !m_nodes_mutex);
958+
void ThreadMessageHandler() EXCLUSIVE_LOCKS_REQUIRED(!mutexMsgProc);
958959
void ThreadI2PAcceptIncoming();
959960
void AcceptConnection(const ListenSocket& hListenSocket);
960961

@@ -1005,7 +1006,7 @@ class CConnman
10051006
/**
10061007
* Check connected and listening sockets for IO readiness and process them accordingly.
10071008
*/
1008-
void SocketHandler() EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex);
1009+
void SocketHandler() EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex, !mutexMsgProc);
10091010

10101011
/**
10111012
* Do the read/write for connected sockets that are ready for IO.
@@ -1019,16 +1020,16 @@ class CConnman
10191020
const std::set<SOCKET>& recv_set,
10201021
const std::set<SOCKET>& send_set,
10211022
const std::set<SOCKET>& error_set)
1022-
EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex);
1023+
EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex, !mutexMsgProc);
10231024

10241025
/**
10251026
* Accept incoming connections, one from each read-ready listening socket.
10261027
* @param[in] recv_set Sockets that are ready for read.
10271028
*/
10281029
void SocketHandlerListening(const std::set<SOCKET>& recv_set);
10291030

1030-
void ThreadSocketHandler() EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex);
1031-
void ThreadDNSAddressSeed();
1031+
void ThreadSocketHandler() EXCLUSIVE_LOCKS_REQUIRED(!m_total_bytes_sent_mutex, !mutexMsgProc);
1032+
void ThreadDNSAddressSeed() EXCLUSIVE_LOCKS_REQUIRED(!m_addr_fetches_mutex, !m_nodes_mutex);
10321033

10331034
uint64_t CalculateKeyedNetGroup(const CAddress& ad) const;
10341035

src/net_processing.cpp

Lines changed: 36 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -431,30 +431,37 @@ class PeerManagerImpl final : public PeerManager
431431
CTxMemPool& pool, bool ignore_incoming_txs);
432432

433433
/** Overridden from CValidationInterface. */
434-
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected) override;
435-
void BlockDisconnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex* pindex) override;
436-
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override;
437-
void BlockChecked(const CBlock& block, const BlockValidationState& state) override;
434+
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected) override
435+
EXCLUSIVE_LOCKS_REQUIRED(!m_recent_confirmed_transactions_mutex);
436+
void BlockDisconnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex* pindex) override
437+
EXCLUSIVE_LOCKS_REQUIRED(!m_recent_confirmed_transactions_mutex);
438+
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override
439+
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
440+
void BlockChecked(const CBlock& block, const BlockValidationState& state) override
441+
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
438442
void NewPoWValidBlock(const CBlockIndex *pindex, const std::shared_ptr<const CBlock>& pblock) override;
439443

440444
/** Implement NetEventsInterface */
441-
void InitializeNode(CNode* pnode) override;
442-
void FinalizeNode(const CNode& node) override;
443-
bool ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt) override;
444-
bool SendMessages(CNode* pto) override EXCLUSIVE_LOCKS_REQUIRED(pto->cs_sendProcessing);
445+
void InitializeNode(CNode* pnode) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
446+
void FinalizeNode(const CNode& node) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
447+
bool ProcessMessages(CNode* pfrom, std::atomic<bool>& interrupt) override
448+
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, !m_recent_confirmed_transactions_mutex);
449+
bool SendMessages(CNode* pto) override EXCLUSIVE_LOCKS_REQUIRED(pto->cs_sendProcessing)
450+
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, !m_recent_confirmed_transactions_mutex);
445451

446452
/** Implement PeerManager */
447453
void StartScheduledTasks(CScheduler& scheduler) override;
448454
void CheckForStaleTipAndEvictPeers() override;
449455
std::optional<std::string> FetchBlock(NodeId peer_id, const CBlockIndex& block_index) override;
450-
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) const override;
456+
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats& stats) const override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
451457
bool IgnoresIncomingTxs() override { return m_ignore_incoming_txs; }
452-
void SendPings() override;
453-
void RelayTransaction(const uint256& txid, const uint256& wtxid) override;
458+
void SendPings() override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
459+
void RelayTransaction(const uint256& txid, const uint256& wtxid) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
454460
void SetBestHeight(int height) override { m_best_height = height; };
455-
void Misbehaving(const NodeId pnode, const int howmuch, const std::string& message) override;
461+
void Misbehaving(const NodeId pnode, const int howmuch, const std::string& message) override EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
456462
void ProcessMessage(CNode& pfrom, const std::string& msg_type, CDataStream& vRecv,
457-
const std::chrono::microseconds time_received, const std::atomic<bool>& interruptMsgProc) override;
463+
const std::chrono::microseconds time_received, const std::atomic<bool>& interruptMsgProc) override
464+
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex, !m_recent_confirmed_transactions_mutex);
458465
void UpdateLastBlockAnnounceTime(NodeId node, int64_t time_in_seconds) override;
459466

460467
private:
@@ -465,15 +472,15 @@ class PeerManagerImpl final : public PeerManager
465472
void EvictExtraOutboundPeers(std::chrono::seconds now) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
466473

467474
/** Retrieve unbroadcast transactions from the mempool and reattempt sending to peers */
468-
void ReattemptInitialBroadcast(CScheduler& scheduler);
475+
void ReattemptInitialBroadcast(CScheduler& scheduler) EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
469476

470477
/** Get a shared pointer to the Peer object.
471478
* May return an empty shared_ptr if the Peer object can't be found. */
472-
PeerRef GetPeerRef(NodeId id) const;
479+
PeerRef GetPeerRef(NodeId id) const EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
473480

474481
/** Get a shared pointer to the Peer object and remove it from m_peer_map.
475482
* May return an empty shared_ptr if the Peer object can't be found. */
476-
PeerRef RemovePeer(NodeId id);
483+
PeerRef RemovePeer(NodeId id) EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
477484

478485
/**
479486
* Potentially mark a node discouraged based on the contents of a BlockValidationState object
@@ -486,14 +493,16 @@ class PeerManagerImpl final : public PeerManager
486493
* @return Returns true if the peer was punished (probably disconnected)
487494
*/
488495
bool MaybePunishNodeForBlock(NodeId nodeid, const BlockValidationState& state,
489-
bool via_compact_block, const std::string& message = "");
496+
bool via_compact_block, const std::string& message = "")
497+
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
490498

491499
/**
492500
* Potentially disconnect and discourage a node based on the contents of a TxValidationState object
493501
*
494502
* @return Returns true if the peer was punished (probably disconnected)
495503
*/
496-
bool MaybePunishNodeForTx(NodeId nodeid, const TxValidationState& state, const std::string& message = "");
504+
bool MaybePunishNodeForTx(NodeId nodeid, const TxValidationState& state, const std::string& message = "")
505+
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
497506

498507
/** Maybe disconnect a peer and discourage future connections from its address.
499508
*
@@ -503,13 +512,16 @@ class PeerManagerImpl final : public PeerManager
503512
*/
504513
bool MaybeDiscourageAndDisconnect(CNode& pnode, Peer& peer);
505514

506-
void ProcessOrphanTx(std::set<uint256>& orphan_work_set) EXCLUSIVE_LOCKS_REQUIRED(cs_main, g_cs_orphans);
515+
void ProcessOrphanTx(std::set<uint256>& orphan_work_set) EXCLUSIVE_LOCKS_REQUIRED(cs_main, g_cs_orphans)
516+
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
507517
/** Process a single headers message from a peer. */
508518
void ProcessHeadersMessage(CNode& pfrom, const Peer& peer,
509519
const std::vector<CBlockHeader>& headers,
510-
bool via_compact_block);
520+
bool via_compact_block)
521+
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
511522

512-
void SendBlockTransactions(CNode& pfrom, const CBlock& block, const BlockTransactionsRequest& req);
523+
void SendBlockTransactions(CNode& pfrom, const CBlock& block, const BlockTransactionsRequest& req)
524+
EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
513525

514526
/** Register with TxRequestTracker that an INV has been received from a
515527
* peer. The announcement parameters are decided in PeerManager and then
@@ -536,7 +548,7 @@ class PeerManagerImpl final : public PeerManager
536548
* @param[in] fReachable Whether the address' network is reachable. We relay unreachable
537549
* addresses less.
538550
*/
539-
void RelayAddress(NodeId originator, const CAddress& addr, bool fReachable);
551+
void RelayAddress(NodeId originator, const CAddress& addr, bool fReachable) EXCLUSIVE_LOCKS_REQUIRED(!m_peer_mutex);
540552

541553
/** Send `feefilter` message. */
542554
void MaybeSendFeefilter(CNode& node, Peer& peer, std::chrono::microseconds current_time);
@@ -606,7 +618,8 @@ class PeerManagerImpl final : public PeerManager
606618
/** Number of preferable block download peers. */
607619
int m_num_preferred_download_peers GUARDED_BY(cs_main){0};
608620

609-
bool AlreadyHaveTx(const GenTxid& gtxid) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
621+
bool AlreadyHaveTx(const GenTxid& gtxid)
622+
EXCLUSIVE_LOCKS_REQUIRED(cs_main, !m_recent_confirmed_transactions_mutex);
610623

611624
/**
612625
* Filter for transactions that were recently rejected by the mempool.

src/qt/clientmodel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class ClientModel : public QObject
6161
//! Return number of connections, default is in- and outbound (total)
6262
int getNumConnections(unsigned int flags = CONNECTIONS_ALL) const;
6363
int getNumBlocks() const;
64-
uint256 getBestBlockHash();
64+
uint256 getBestBlockHash() EXCLUSIVE_LOCKS_REQUIRED(!m_cached_tip_mutex);
6565
int getHeaderTipHeight() const;
6666
int64_t getHeaderTipTime() const;
6767

src/random.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ class RNGState {
374374
{
375375
}
376376

377-
void AddEvent(uint32_t event_info) noexcept
377+
void AddEvent(uint32_t event_info) noexcept EXCLUSIVE_LOCKS_REQUIRED(!m_events_mutex)
378378
{
379379
LOCK(m_events_mutex);
380380

@@ -388,7 +388,7 @@ class RNGState {
388388
/**
389389
* Feed (the hash of) all events added through AddEvent() to hasher.
390390
*/
391-
void SeedEvents(CSHA512& hasher) noexcept
391+
void SeedEvents(CSHA512& hasher) noexcept EXCLUSIVE_LOCKS_REQUIRED(!m_events_mutex)
392392
{
393393
// We use only SHA256 for the events hashing to get the ASM speedups we have for SHA256,
394394
// since we want it to be fast as network peers may be able to trigger it repeatedly.
@@ -407,7 +407,7 @@ class RNGState {
407407
*
408408
* If this function has never been called with strong_seed = true, false is returned.
409409
*/
410-
bool MixExtract(unsigned char* out, size_t num, CSHA512&& hasher, bool strong_seed) noexcept
410+
bool MixExtract(unsigned char* out, size_t num, CSHA512&& hasher, bool strong_seed) noexcept EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
411411
{
412412
assert(num <= 32);
413413
unsigned char buf[64];

0 commit comments

Comments
 (0)