From aafded67d97c5459ff4d2846ed9417dc4292015a Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sat, 10 Aug 2024 14:45:45 +0000 Subject: [PATCH 1/2] fix: compilation error due to rebase error between bitcoin#22937 and ipc/process --- src/ipc/process.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ipc/process.cpp b/src/ipc/process.cpp index 43ed1f1baeb02..9036b80c45c4f 100644 --- a/src/ipc/process.cpp +++ b/src/ipc/process.cpp @@ -30,8 +30,8 @@ class ProcessImpl : public Process return mp::SpawnProcess(pid, [&](int fd) { fs::path path = argv0_path; path.remove_filename(); - path.append(new_exe_name); - return std::vector{path.string(), "-ipcfd", strprintf("%i", fd)}; + path /= fs::PathFromString(new_exe_name); + return std::vector{fs::PathToString(path), "-ipcfd", strprintf("%i", fd)}; }); } int waitSpawned(int pid) override { return mp::WaitProcess(pid); } From 540f6871d3acdfc7c890cbc9d61d4cd9b3add974 Mon Sep 17 00:00:00 2001 From: Kittywhiskers Van Gogh <63189531+kwvg@users.noreply.github.com> Date: Sat, 10 Aug 2024 16:35:27 +0000 Subject: [PATCH 2/2] fix: lock `::cs_main` before accessing `ChainstateManager::m_best_header` Avoid TSan-reported data race ``` WARNING: ThreadSanitizer: data race (pid=360336) Write of size 8 at 0x7b5000002db8 by thread T15 (mutexes: write M0): #0 BlockManager::AddToBlockIndex(CBlockHeader const&, uint256 const&, CBlockIndex*&, BlockStatus) /src/dash/src/node/blockstorage.cpp:117:25 (dashd+0x44df7a) (BuildId: e27186c7ba08e897d376eb5779db9809baf7ad37) #1 ChainstateManager::AcceptBlockHeader(CBlockHeader const&, BlockValidationState&, CChainParams const&, CBlockIndex**) /src/dash/src/validation.cpp:3758:36 (dashd+0x83e45d) (BuildId: e27186c7ba08e897d376eb5779db9809baf7ad37) #2 CChainState::AcceptBlock(std::shared_ptr const&, BlockValidationState&, CBlockIndex**, bool, FlatFilePos const*, bool*) /src/dash/src/validation.cpp:3812:37 (dashd+0x842848) (BuildId: e27186c7ba08e897d376eb5779db9809baf7ad37) [...] Previous read of size 8 at 0x7b5000002db8 by thread T12: #0 CDSNotificationInterface::UpdatedBlockTip(CBlockIndex const*, CBlockIndex const*, bool) /src/dash/src/dsnotificationinterface.cpp:82:42 (dashd+0x91e87e) (BuildId: e27186c7ba08e897d376eb5779db9809baf7ad37) #1 operator() /src/dash/src/validationinterface.cpp:199:79 (dashd+0x889f1e) (BuildId: e27186c7ba08e897d376eb5779db9809baf7ad37) #2 Iterate<(lambda at validationinterface.cpp:199:30)> /src/dash/src/validationinterface.cpp:88:17 (dashd+0x889f1e) [...] [...] SUMMARY: ThreadSanitizer: data race [...] ``` --- src/dsnotificationinterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dsnotificationinterface.cpp b/src/dsnotificationinterface.cpp index cb0e44e21bcb4..e5b7613650cf6 100644 --- a/src/dsnotificationinterface.cpp +++ b/src/dsnotificationinterface.cpp @@ -79,7 +79,7 @@ void CDSNotificationInterface::UpdatedBlockTip(const CBlockIndex *pindexNew, con if (pindexNew == pindexFork) // blocks were disconnected without any new ones return; - m_mn_sync.UpdatedBlockTip(m_chainman.m_best_header, pindexNew, fInitialDownload); + m_mn_sync.UpdatedBlockTip(WITH_LOCK(::cs_main, return m_chainman.m_best_header), pindexNew, fInitialDownload); // Update global DIP0001 activation status fDIP0001ActiveAtTip = pindexNew->nHeight >= Params().GetConsensus().DIP0001Height;