Skip to content

Commit cb52cee

Browse files
committed
Merge #14993: rpc: Fix data race (UB) in InterruptRPC()
6c10037 rpc: Fix data race (UB) in InterruptRPC() (practicalswift) Pull request description: Fix data race (UB) in `InterruptRPC()`. Before: ``` $ ./configure --with-sanitizers=thread $ make $ test/functional/test_runner.py feature_shutdown.py … SUMMARY: ThreadSanitizer: data race rpc/server.cpp:314 in InterruptRPC() … ALL | ✖ Failed | 2 s (accumulated) ``` After: ``` $ ./configure --with-sanitizers=thread $ make $ test/functional/test_runner.py feature_shutdown.py … ALL | ✓ Passed | 3 s (accumulated) ``` Tree-SHA512: b139ca1a0480258f8caa7730cabd7783a821d906630f51487750a6b15b7842675ed679747e1ff1bdade77d248807e9d77bae7bb88da54d1df84a179cd9b9b987
2 parents f080c65 + 6c10037 commit cb52cee

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

src/rpc/server.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <unordered_map>
2525

2626
static CCriticalSection cs_rpcWarmup;
27-
static bool fRPCRunning = false;
27+
static std::atomic<bool> g_rpc_running{false};
2828
static bool fRPCInWarmup GUARDED_BY(cs_rpcWarmup) = true;
2929
static std::string rpcWarmupStatus GUARDED_BY(cs_rpcWarmup) = "RPC server started";
3030
/* Timer-creating functions */
@@ -303,15 +303,15 @@ bool CRPCTable::appendCommand(const std::string& name, const CRPCCommand* pcmd)
303303
void StartRPC()
304304
{
305305
LogPrint(BCLog::RPC, "Starting RPC\n");
306-
fRPCRunning = true;
306+
g_rpc_running = true;
307307
g_rpcSignals.Started();
308308
}
309309

310310
void InterruptRPC()
311311
{
312312
LogPrint(BCLog::RPC, "Interrupting RPC\n");
313313
// Interrupt e.g. running longpolls
314-
fRPCRunning = false;
314+
g_rpc_running = false;
315315
}
316316

317317
void StopRPC()
@@ -324,7 +324,7 @@ void StopRPC()
324324

325325
bool IsRPCRunning()
326326
{
327-
return fRPCRunning;
327+
return g_rpc_running;
328328
}
329329

330330
void SetRPCWarmupStatus(const std::string& newStatus)

test/sanitizer_suppressions/tsan

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ deadlock:WalletBatch
77
# Intentional deadlock in tests
88
deadlock:TestPotentialDeadLockDetected
99

10-
# fRPCRunning race
11-
race:InterruptRPC
12-
1310
# Wildcard for all gui tests, should be replaced with non-wildcard suppressions
1411
race:src/qt/test/*
1512
deadlock:src/qt/test/*

0 commit comments

Comments
 (0)