aboutsummaryrefslogtreecommitdiff
path: root/src/random.cpp
diff options
context:
space:
mode:
authorMacroFake <falke.marco@gmail.com>2022-05-16 14:17:57 +0200
committerMacroFake <falke.marco@gmail.com>2022-05-16 14:18:08 +0200
commitaa3200d8967215dc93ea75e19db0aca537ec3d35 (patch)
tree89cafefdbb20363b04ba4a0bfd9fce0d343942fa /src/random.cpp
parentdc0ee573734ed49c054bfa3b97f1785c755dd0c3 (diff)
parent436ce0233c276e263dcb441255dc0b881cb39cfb (diff)
downloadbitcoin-aa3200d8967215dc93ea75e19db0aca537ec3d35.tar.xz
Merge bitcoin/bitcoin#25109: Strengthen AssertLockNotHeld assertions
436ce0233c276e263dcb441255dc0b881cb39cfb sync.h: strengthen AssertLockNotHeld assertion (Anthony Towns) 7d73f58e9cea8f4b0bc16512983898fddde3d764 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 436ce0233c276e263dcb441255dc0b881cb39cfb MarcoFalke: review ACK 436ce0233c276e263dcb441255dc0b881cb39cfb 🌺 Tree-SHA512: 5f16d098790a36b5277324d5ee89cdc87033c19b11c7943c2f630a41c2e3998eb39d356a763e857f4d8fefb6c0c02291f720bb6769bcbdf5e2cd765bf266ab8c
Diffstat (limited to 'src/random.cpp')
-rw-r--r--src/random.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/random.cpp b/src/random.cpp
index ad8568bef0..ec4e44ccc2 100644
--- a/src/random.cpp
+++ b/src/random.cpp
@@ -374,7 +374,7 @@ public:
{
}
- void AddEvent(uint32_t event_info) noexcept
+ void AddEvent(uint32_t event_info) noexcept EXCLUSIVE_LOCKS_REQUIRED(!m_events_mutex)
{
LOCK(m_events_mutex);
@@ -388,7 +388,7 @@ public:
/**
* Feed (the hash of) all events added through AddEvent() to hasher.
*/
- void SeedEvents(CSHA512& hasher) noexcept
+ void SeedEvents(CSHA512& hasher) noexcept EXCLUSIVE_LOCKS_REQUIRED(!m_events_mutex)
{
// We use only SHA256 for the events hashing to get the ASM speedups we have for SHA256,
// since we want it to be fast as network peers may be able to trigger it repeatedly.
@@ -407,7 +407,7 @@ public:
*
* If this function has never been called with strong_seed = true, false is returned.
*/
- bool MixExtract(unsigned char* out, size_t num, CSHA512&& hasher, bool strong_seed) noexcept
+ bool MixExtract(unsigned char* out, size_t num, CSHA512&& hasher, bool strong_seed) noexcept EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
{
assert(num <= 32);
unsigned char buf[64];