Repository: bitcoin
Issue: wallet: Data race in GetOrCreateLegacyScriptPubKeyMan vs IsMine
Labels: Bug,Wallet,CI failed

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current behaviour

tsan error

### Expected behaviour

no tsan error

### Steps to reproduce

I presume the error is intermittent, but the basic idea is that the validation interface thread (scheduler) may connect blocks and sync wallet transactions, thus call `IsMine` and access `m_spk_managers`. At the same time, the main thread may call `GetOrCreateLegacyScriptPubKeyMan`, also accessing `m_spk_managers`, thus running into a race.

This happens in tests, see below.

However, I think this may also happen in production, so a proper fix would be to protect `m_spk_managers` with a mutex? If not, it might be sufficient to add a `SyncWithValidationInterfaceQueue()` somewhere in the test.

### Relevant log output

https://cirrus-ci.com/task/6202645656895488?logs=check#L3078

```
wallet/test/wallet_tests.cpp(430): Leaving test case "LoadReceiveRequests"; testing time: 72958us
wallet/test/wallet_tests.cpp(491): Entering test case "WatchOnlyPubKeys"
2023-03-26T06:23:28.508912Z [test] [test/util/setup_common.cpp:90] [Seed] Seed: Setting random seed for current tests to RANDOM_CTX_SEED=76c898d9e4bcec2024b506a637197960a4dd511e4d7efc74bda42b593ffa946e
2023-03-26T06:23:28.509010Z [test] [init/common.cpp:149] [LogPackageVersion] Bitcoin Core version v24.99.0-e352f5ab6b60 (release build)
2023-03-26T06:23:28.509290Z [test] [kernel/context.cpp:21] [Context] Using the 'x86_shani(1way,2way)' SHA256 implementation
2023-03-26T06:23:28.509321Z [test] [random.cpp:99] [ReportHardwareRand] Using RdSeed as an additional entropy source
2023-03-26T06:23:28.509340Z [test] [random.cpp:102] [ReportHardwareRand] Using RdRand as an additional entropy source
2023-03-26T06:23:28.531198Z [test] [script/sigcache.cpp:103] [InitSignatureCache] Using 16 MiB out of 16 MiB requested for signature cache, able to store 524288 elements
2023-03-26T06:23:28.552320Z [test] [validation.cpp:1746] [InitScriptExecutionCache] Using 16 MiB out of 16 MiB requested for script execution cache, able to store 524288 elements
2023-03-26T06:23:28.552562Z [scheduler] [util/thread.cpp:20] [TraceThread] scheduler thread start
2023-03-26T06:23:28.614893Z [test] [policy/fees.cpp:551] [CBlockPolicyEstimator] Failed to read fee estimates from /tmp/test_common_Bitcoin Core/8c8d5cefbd9d876fe95b7ed8e54bcbb495acc1633fa2a0c21901247b82e65657/fee_estimates.dat. Continue anyway.
2023-03-26T06:23:28.615452Z [test] [dbwrapper.cpp:158] [CDBWrapper] Opened LevelDB successfully
2023-03-26T06:23:28.615506Z [test] [dbwrapper.cpp:183] [CDBWrapper] Using obfuscation key for /tmp/test_common_Bitcoin Core/8c8d5cefbd9d876fe95b7ed8e54bcbb495acc1633fa2a0c21901247b82e65657/blocks/index: 0000000000000000
2023-03-26T06:23:28.616680Z [test] [node/chainstate.cpp:164] [LoadChainstate] Assuming ancestors of block 00000000000000000009c97098b5295f7e5f183ac811fb5d1534040adb93cabd have valid signatures.
2023-03-26T06:23:28.625895Z [test] [node/chainstate.cpp:168] [LoadChainstate] Setting nMinimumChainWork=00000000000000000000000000000000000000003404ba0801921119f903495e
2023-03-26T06:23:28.626343Z [test] [dbwrapper.cpp:158] [CDBWrapper] Opened LevelDB successfully
2023-03-26T06:23:28.626395Z [test] [dbwrapper.cpp:183] [CDBWrapper] Using obfuscation key for /tmp/test_common_Bitcoin Core/8c8d5cefbd9d876fe95b7ed8e54bcbb495acc1633fa2a0c21901247b82e65657/blocks/index: 0000000000000000
2023-03-26T06:23:28.626449Z [test] [node/blockstorage.cpp:329] [LoadBlockIndexDB] LoadBlockIndexDB: last block file = 0
2023-03-26T06:23:28.626493Z [test] [node/blockstorage.cpp:333] [LoadBlockIndexDB] LoadBlockIndexDB: last block file info: CBlockFileInfo(blocks=0, size=0, heights=0...0, time=1970-01-01...1970-01-01)
2023-03-26T06:23:28.626522Z [test] [node/blockstorage.cpp:344] [LoadBlockIndexDB] Checking all blk files are present...
2023-03-26T06:23:28.626559Z [test] [validation.cpp:4493] [LoadBlockIndex] Initializing databases...
2023-03-26T06:23:28.626732Z [test] [flatfile.cpp:69] [Allocate] [validation] Pre-allocating up to position 0x1000000 in blk00000.dat
2023-03-26T06:23:28.626883Z [test] [node/chainstate.cpp:106] [CompleteChainstateInitialization] Initializing chainstate Chainstate [ibd] @ height -1 (null)
2023-03-26T06:23:28.627148Z [test] [dbwrapper.cpp:158] [CDBWrapper] Opened LevelDB successfully
2023-03-26T06:23:28.627227Z [test] [dbwrapper.cpp:180] [CDBWrapper] Wrote new obfuscate key for /tmp/test_common_Bitcoin Core/8c8d5cefbd9d876fe95b7ed8e54bcbb495acc1633fa2a0c21901247b82e65657/chainstate: d296978c75cdee55
2023-03-26T06:23:28.627255Z [test] [dbwrapper.cpp:183] [CDBWrapper] Using obfuscation key for /tmp/test_common_Bitcoin Core/8c8d5cefbd9d876fe95b7ed8e54bcbb495acc1633fa2a0c21901247b82e65657/chainstate: d296978c75cdee55
2023-03-26T06:23:28.627324Z [test] [validation.cpp:5538] [MaybeRebalanceCaches] [snapshot] allocating all cache to the IBD chainstate
2023-03-26T06:23:28.627366Z [test] [validation.cpp:4920] [ResizeCoinsCaches] [Chainstate [ibd] @ height -1 (null)] resized coinsdb cache to 8.0 MiB
2023-03-26T06:23:28.627394Z [test] [validation.cpp:4922]==================
WARNING: ThreadSanitizer: data race (pid=31396)
  Read of size 8 at 0x7b1400034d90 by thread T19 (mutexes: write M0):
    #0 std::__uniq_ptr_impl<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>::_M_ptr() const /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/unique_ptr.h:191:51 (test_bitcoin+0xd79cb8) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #1 std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>::get() const /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/unique_ptr.h:462:21 (test_bitcoin+0xd79cb8)
    #2 std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>::operator->() const /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/unique_ptr.h:455:9 (test_bitcoin+0xd79cb8)
    #3 wallet::CWallet::IsMine(CScript const&) const src/wallet/wallet.cpp:1515:35 (test_bitcoin+0xd79cb8)
    #4 wallet::CWallet::IsMine(CTxOut const&) const src/wallet/wallet.cpp:1501:12 (test_bitcoin+0xd79cb8)
    #5 wallet::CWallet::IsMine(CTransaction const&) const src/wallet/wallet.cpp:1524:13 (test_bitcoin+0xd79cb8)
    #6 wallet::CWallet::AddToWalletIfInvolvingMe(std::shared_ptr<CTransaction const> const&, std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateInactive> const&, bool, bool) src/wallet/wallet.cpp:1207:25 (test_bitcoin+0xd79cb8)
    #7 wallet::CWallet::SyncTransaction(std::shared_ptr<CTransaction const> const&, std::variant<wallet::TxStateConfirmed, wallet::TxStateInMempool, wallet::TxStateInactive> const&, bool, bool) src/wallet/wallet.cpp:1380:10 (test_bitcoin+0xd7cffa) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #8 wallet::CWallet::blockConnected(interfaces::BlockInfo const&) src/wallet/wallet.cpp:1444:9 (test_bitcoin+0xd7cffa)
    #9 non-virtual thunk to wallet::CWallet::blockConnected(interfaces::BlockInfo const&) src/wallet/wallet.cpp (test_bitcoin+0xd7d243) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #10 node::(anonymous namespace)::NotificationsProxy::BlockConnected(std::shared_ptr<CBlock const> const&, CBlockIndex const*) src/node/interfaces.cpp:431:26 (test_bitcoin+0x11183f8) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #11 CMainSignals::BlockConnected(std::shared_ptr<CBlock const> const&, CBlockIndex const*)::$_1::operator()() const::'lambda'(CValidationInterface&)::operator()(CValidationInterface&) const src/validationinterface.cpp:228:79 (test_bitcoin+0x13ef9a2) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #12 void MainSignalsImpl::Iterate<CMainSignals::BlockConnected(std::shared_ptr<CBlock const> const&, CBlockIndex const*)::$_1::operator()() const::'lambda'(CValidationInterface&)>(CMainSignals::BlockConnected(std::shared_ptr<CBlock const> const&, CBlockIndex const*)::$_1::operator()() const::'lambda'(CValidationInterface&)&&) src/validationinterface.cpp:88:17 (test_bitcoin+0x13ef9a2)
    #13 CMainSignals::BlockConnected(std::shared_ptr<CBlock const> const&, CBlockIndex const*)::$_1::operator()() const src/validationinterface.cpp:228:22 (test_bitcoin+0x13ef9a2)
    #14 CMainSignals::BlockConnected(std::shared_ptr<CBlock const> const&, CBlockIndex const*)::$_0::operator()() const src/validationinterface.cpp:230:5 (test_bitcoin+0x13ef9a2)
    #15 void std::__invoke_impl<void, CMainSignals::BlockConnected(std::shared_ptr<CBlock const> const&, CBlockIndex const*)::$_0&>(std::__invoke_other, CMainSignals::BlockConnected(std::shared_ptr<CBlock const> const&, CBlockIndex const*)::$_0&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/invoke.h:61:14 (test_bitcoin+0x13ef9a2)
    #16 std::enable_if<is_invocable_r_v<void, CMainSignals::BlockConnected(std::shared_ptr<CBlock const> const&, CBlockIndex const*)::$_0&>, void>::type std::__invoke_r<void, CMainSignals::BlockConnected(std::shared_ptr<CBlock const> const&, CBlockIndex const*)::$_0&>(CMainSignals::BlockConnected(std::shared_ptr<CBlock const> const&, CBlockIndex const*)::$_0&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/invoke.h:111:2 (test_bitcoin+0x13ef9a2)
    #17 std::_Function_handler<void (), CMainSignals::BlockConnected(std::shared_ptr<CBlock const> const&, CBlockIndex const*)::$_0>::_M_invoke(std::_Any_data const&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_function.h:290:9 (test_bitcoin+0x13ef9a2)
    #18 std::function<void ()>::operator()() const /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_function.h:591:9 (test_bitcoin+0x14b4f0c) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #19 SingleThreadedSchedulerClient::ProcessQueue() src/scheduler.cpp:175:5 (test_bitcoin+0x14b4f0c)
    #20 SingleThreadedSchedulerClient::MaybeScheduleProcessQueue()::$_0::operator()() const src/scheduler.cpp:144:41 (test_bitcoin+0x14b5ee3) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #21 void std::__invoke_impl<void, SingleThreadedSchedulerClient::MaybeScheduleProcessQueue()::$_0&>(std::__invoke_other, SingleThreadedSchedulerClient::MaybeScheduleProcessQueue()::$_0&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/invoke.h:61:14 (test_bitcoin+0x14b5ee3)
    #22 std::enable_if<is_invocable_r_v<void, SingleThreadedSchedulerClient::MaybeScheduleProcessQueue()::$_0&>, void>::type std::__invoke_r<void, SingleThreadedSchedulerClient::MaybeScheduleProcessQueue()::$_0&>(SingleThreadedSchedulerClient::MaybeScheduleProcessQueue()::$_0&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/invoke.h:111:2 (test_bitcoin+0x14b5ee3)
    #23 std::_Function_handler<void (), SingleThreadedSchedulerClient::MaybeScheduleProcessQueue()::$_0>::_M_invoke(std::_Any_data const&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_function.h:290:9 (test_bitcoin+0x14b5ee3)
    #24 std::function<void ()>::operator()() const /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_function.h:591:9 (test_bitcoin+0x14b3ecd) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #25 CScheduler::serviceQueue() src/scheduler.cpp:62:17 (test_bitcoin+0x14b3ecd)
    #26 ChainTestingSetup::ChainTestingSetup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<char const*, std::allocator<char const*>> const&)::$_0::operator()() const src/test/util/setup_common.cpp:173:110 (test_bitcoin+0xc1d226) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #27 void std::__invoke_impl<void, ChainTestingSetup::ChainTestingSetup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<char const*, std::allocator<char const*>> const&)::$_0&>(std::__invoke_other, ChainTestingSetup::ChainTestingSetup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<char const*, std::allocator<char const*>> const&)::$_0&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/invoke.h:61:14 (test_bitcoin+0xc1d226)
    #28 std::enable_if<is_invocable_r_v<void, ChainTestingSetup::ChainTestingSetup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<char const*, std::allocator<char const*>> const&)::$_0&>, void>::type std::__invoke_r<void, ChainTestingSetup::ChainTestingSetup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<char const*, std::allocator<char const*>> const&)::$_0&>(ChainTestingSetup::ChainTestingSetup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<char const*, std::allocator<char const*>> const&)::$_0&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/invoke.h:111:2 (test_bitcoin+0xc1d226)
    #29 std::_Function_handler<void (), ChainTestingSetup::ChainTestingSetup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<char const*, std::allocator<char const*>> const&)::$_0>::_M_invoke(std::_Any_data const&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_function.h:290:9 (test_bitcoin+0xc1d226)
    #30 std::function<void ()>::operator()() const /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_function.h:591:9 (test_bitcoin+0x157a6d9) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #31 util::TraceThread(std::basic_string_view<char, std::char_traits<char>>, std::function<void ()>) src/util/thread.cpp:21:9 (test_bitcoin+0x157a6d9)
    #32 void std::__invoke_impl<void, void (*)(std::basic_string_view<char, std::char_traits<char>>, std::function<void ()>), char const*, ChainTestingSetup::ChainTestingSetup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<char const*, std::allocator<char const*>> const&)::$_0>(std::__invoke_other, void (*&&)(std::basic_string_view<char, std::char_traits<char>>, std::function<void ()>), char const*&&, ChainTestingSetup::ChainTestingSetup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<char const*, std::allocator<char const*>> const&)::$_0&&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/invoke.h:61:14 (test_bitcoin+0xc1d132) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #33 std::__invoke_result<void (*)(std::basic_string_view<char, std::char_traits<char>>, std::function<void ()>), char const*, ChainTestingSetup::ChainTestingSetup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<char const*, std::allocator<char const*>> const&)::$_0>::type std::__invoke<void (*)(std::basic_string_view<char, std::char_traits<char>>, std::function<void ()>), char const*, ChainTestingSetup::ChainTestingSetup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<char const*, std::allocator<char const*>> const&)::$_0>(void (*&&)(std::basic_string_view<char, std::char_traits<char>>, std::function<void ()>), char const*&&, ChainTestingSetup::ChainTestingSetup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<char const*, std::allocator<char const*>> const&)::$_0&&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/invoke.h:96:14 (test_bitcoin+0xc1d132)
    #34 void std::thread::_Invoker<std::tuple<void (*)(std::basic_string_view<char, std::char_traits<char>>, std::function<void ()>), char const*, ChainTestingSetup::ChainTestingSetup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<char const*, std::allocator<char const*>> const&)::$_0>>::_M_invoke<0ul, 1ul, 2ul>(std::_Index_tuple<0ul, 1ul, 2ul>) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_thread.h:252:13 (test_bitcoin+0xc1d132)
    #35 std::thread::_Invoker<std::tuple<void (*)(std::basic_string_view<char, std::char_traits<char>>, std::function<void ()>), char const*, ChainTestingSetup::ChainTestingSetup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<char const*, std::allocator<char const*>> const&)::$_0>>::operator()() /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_thread.h:259:11 (test_bitcoin+0xc1d132)
    #36 std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(std::basic_string_view<char, std::char_traits<char>>, std::function<void ()>), char const*, ChainTestingSetup::ChainTestingSetup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<char const*, std::allocator<char const*>> const&)::$_0>>>::_M_run() /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/std_thread.h:210:13 (test_bitcoin+0xc1d132)
    #37 <null> <null> (libstdc++.so.6+0xdc472) (BuildId: d8f370a6195f115a4e221070f20de2c68d281b66)
  Previous write of size 8 at 0x7b1400034d90 by main thread:
    #0 operator new(unsigned long) <null> (test_bitcoin+0x1c36a7) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #1 std::__new_allocator<std::_Rb_tree_node<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>>::allocate(unsigned long, void const*) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/new_allocator.h:137:27 (test_bitcoin+0xdbdd38) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #2 std::allocator_traits<std::allocator<std::_Rb_tree_node<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>>>::allocate(std::allocator<std::_Rb_tree_node<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>>&, unsigned long) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/alloc_traits.h:464:20 (test_bitcoin+0xdbdd38)
    #3 std::_Rb_tree<uint256, std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>, std::_Select1st<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>, std::less<uint256>, std::allocator<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>>::_M_get_node() /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_tree.h:561:16 (test_bitcoin+0xdbdd38)
    #4 std::_Rb_tree_node<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>* std::_Rb_tree<uint256, std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>, std::_Select1st<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>, std::less<uint256>, std::allocator<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>>::_M_create_node<std::piecewise_construct_t const&, std::tuple<uint256&&>, std::tuple<>>(std::piecewise_construct_t const&, std::tuple<uint256&&>&&, std::tuple<>&&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_tree.h:611:23 (test_bitcoin+0xdbdd38)
    #5 std::_Rb_tree<uint256, std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>, std::_Select1st<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>, std::less<uint256>, std::allocator<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>>::_Auto_node::_Auto_node<std::piecewise_construct_t const&, std::tuple<uint256&&>, std::tuple<>>(std::_Rb_tree<uint256, std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>, std::_Select1st<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>, std::less<uint256>, std::allocator<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>>&, std::piecewise_construct_t const&, std::tuple<uint256&&>&&, std::tuple<>&&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_tree.h:1636:18 (test_bitcoin+0xdbdd38)
    #6 std::_Rb_tree_iterator<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>> std::_Rb_tree<uint256, std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>, std::_Select1st<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>, std::less<uint256>, std::allocator<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>>::_M_emplace_hint_unique<std::piecewise_construct_t const&, std::tuple<uint256&&>, std::tuple<>>(std::_Rb_tree_const_iterator<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>, std::piecewise_construct_t const&, std::tuple<uint256&&>&&, std::tuple<>&&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_tree.h:2461:13 (test_bitcoin+0xdbdd38)
    #7 std::map<uint256, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>, std::less<uint256>, std::allocator<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>>::operator[](uint256&&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_map.h:530:15 (test_bitcoin+0xd8d236) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #8 wallet::CWallet::SetupLegacyScriptPubKeyMan() src/wallet/wallet.cpp:3552:5 (test_bitcoin+0xd8d236)
    #9 wallet::CWallet::GetOrCreateLegacyScriptPubKeyMan() src/wallet/wallet.cpp:3537:5 (test_bitcoin+0xd8fcdd) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #10 wallet::wallet_tests::WatchOnlyPubKeys::test_method() src/wallet/test/wallet_tests.cpp:495:47 (test_bitcoin+0xb6854b) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #11 wallet::wallet_tests::WatchOnlyPubKeys_invoker() src/wallet/test/wallet_tests.cpp:491:1 (test_bitcoin+0xb67fe2) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #12 boost::detail::function::void_function_invoker0<void (*)(), void>::invoke(boost::detail::function::function_buffer&) /usr/include/boost/function/function_template.hpp:117:11 (test_bitcoin+0x2edd5d) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #13 boost::function0<void>::operator()() const /usr/include/boost/function/function_template.hpp:763:14 (test_bitcoin+0x2629e8) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #14 boost::detail::forward::operator()() /usr/include/boost/test/impl/execution_monitor.ipp:1388:32 (test_bitcoin+0x2629e8)
    #15 boost::detail::function::function_obj_invoker0<boost::detail::forward, int>::invoke(boost::detail::function::function_buffer&) /usr/include/boost/function/function_template.hpp:137:18 (test_bitcoin+0x2629e8)
    #16 boost::function0<int>::operator()() const /usr/include/boost/function/function_template.hpp:763:14 (test_bitcoin+0x1e3a63) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #17 int boost::detail::do_invoke<boost::shared_ptr<boost::detail::translator_holder_base>, boost::function<int ()>>(boost::shared_ptr<boost::detail::translator_holder_base> const&, boost::function<int ()> const&) /usr/include/boost/test/impl/execution_monitor.ipp:301:30 (test_bitcoin+0x1e3a63)
    #18 boost::execution_monitor::catch_signals(boost::function<int ()> const&) /usr/include/boost/test/impl/execution_monitor.ipp:903:16 (test_bitcoin+0x1e3a63)
    #19 boost::execution_monitor::execute(boost::function<int ()> const&) /usr/include/boost/test/impl/execution_monitor.ipp:1301:16 (test_bitcoin+0x1e3e1a) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #20 boost::execution_monitor::vexecute(boost::function<void ()> const&) /usr/include/boost/test/impl/execution_monitor.ipp:1397:5 (test_bitcoin+0x1df504) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #21 boost::unit_test::unit_test_monitor_t::execute_and_translate(boost::function<void ()> const&, unsigned long) /usr/include/boost/test/impl/unit_test_monitor.ipp:49:9 (test_bitcoin+0x1df504)
    #22 boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /usr/include/boost/test/impl/framework.ipp:815:44 (test_bitcoin+0x217c0e) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #23 boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /usr/include/boost/test/impl/framework.ipp:740:54 (test_bitcoin+0x217e20) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #24 boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /usr/include/boost/test/impl/framework.ipp:740:54 (test_bitcoin+0x217e20) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #25 boost::unit_test::framework::run(unsigned long, bool) /usr/include/boost/test/impl/framework.ipp:1722:29 (test_bitcoin+0x1de218) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #26 boost::unit_test::unit_test_main(boost::unit_test::test_suite* (*)(int, char**), int, char**) /usr/include/boost/test/impl/unit_test_main.ipp:250:9 (test_bitcoin+0x1fbd28) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #27 main /usr/include/boost/test/impl/unit_test_main.ipp:306:12 (test_bitcoin+0x1fc2c3) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
  Location is heap block of size 72 at 0x7b1400034d50 allocated by main thread:
    #0 operator new(unsigned long) <null> (test_bitcoin+0x1c36a7) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #1 std::__new_allocator<std::_Rb_tree_node<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>>::allocate(unsigned long, void const*) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/new_allocator.h:137:27 (test_bitcoin+0xdbdd38) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #2 std::allocator_traits<std::allocator<std::_Rb_tree_node<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>>>::allocate(std::allocator<std::_Rb_tree_node<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>>&, unsigned long) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/alloc_traits.h:464:20 (test_bitcoin+0xdbdd38)
    #3 std::_Rb_tree<uint256, std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>, std::_Select1st<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>, std::less<uint256>, std::allocator<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>>::_M_get_node() /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_tree.h:561:16 (test_bitcoin+0xdbdd38)
    #4 std::_Rb_tree_node<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>* std::_Rb_tree<uint256, std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>, std::_Select1st<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>, std::less<uint256>, std::allocator<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>>::_M_create_node<std::piecewise_construct_t const&, std::tuple<uint256&&>, std::tuple<>>(std::piecewise_construct_t const&, std::tuple<uint256&&>&&, std::tuple<>&&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_tree.h:611:23 (test_bitcoin+0xdbdd38)
    #5 std::_Rb_tree<uint256, std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>, std::_Select1st<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>, std::less<uint256>, std::allocator<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>>::_Auto_node::_Auto_node<std::piecewise_construct_t const&, std::tuple<uint256&&>, std::tuple<>>(std::_Rb_tree<uint256, std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>, std::_Select1st<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>, std::less<uint256>, std::allocator<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>>&, std::piecewise_construct_t const&, std::tuple<uint256&&>&&, std::tuple<>&&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_tree.h:1636:18 (test_bitcoin+0xdbdd38)
    #6 std::_Rb_tree_iterator<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>> std::_Rb_tree<uint256, std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>, std::_Select1st<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>, std::less<uint256>, std::allocator<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>>::_M_emplace_hint_unique<std::piecewise_construct_t const&, std::tuple<uint256&&>, std::tuple<>>(std::_Rb_tree_const_iterator<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>, std::piecewise_construct_t const&, std::tuple<uint256&&>&&, std::tuple<>&&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_tree.h:2461:13 (test_bitcoin+0xdbdd38)
    #7 std::map<uint256, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>, std::less<uint256>, std::allocator<std::pair<uint256 const, std::unique_ptr<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>>>>::operator[](uint256&&) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_map.h:530:15 (test_bitcoin+0xd8d236) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #8 wallet::CWallet::SetupLegacyScriptPubKeyMan() src/wallet/wallet.cpp:3552:5 (test_bitcoin+0xd8d236)
    #9 wallet::CWallet::GetOrCreateLegacyScriptPubKeyMan() src/wallet/wallet.cpp:3537:5 (test_bitcoin+0xd8fcdd) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #10 wallet::wallet_tests::WatchOnlyPubKeys::test_method() src/wallet/test/wallet_tests.cpp:495:47 (test_bitcoin+0xb6854b) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #11 wallet::wallet_tests::WatchOnlyPubKeys_invoker() src/wallet/test/wallet_tests.cpp:491:1 (test_bitcoin+0xb67fe2) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #12 boost::detail::function::void_function_invoker0<void (*)(), void>::invoke(boost::detail::function::function_buffer&) /usr/include/boost/function/function_template.hpp:117:11 (test_bitcoin+0x2edd5d) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #13 boost::function0<void>::operator()() const /usr/include/boost/function/function_template.hpp:763:14 (test_bitcoin+0x2629e8) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #14 boost::detail::forward::operator()() /usr/include/boost/test/impl/execution_monitor.ipp:1388:32 (test_bitcoin+0x2629e8)
    #15 boost::detail::function::function_obj_invoker0<boost::detail::forward, int>::invoke(boost::detail::function::function_buffer&) /usr/include/boost/function/function_template.hpp:137:18 (test_bitcoin+0x2629e8)
    #16 boost::function0<int>::operator()() const /usr/include/boost/function/function_template.hpp:763:14 (test_bitcoin+0x1e3a63) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #17 int boost::detail::do_invoke<boost::shared_ptr<boost::detail::translator_holder_base>, boost::function<int ()>>(boost::shared_ptr<boost::detail::translator_holder_base> const&, boost::function<int ()> const&) /usr/include/boost/test/impl/execution_monitor.ipp:301:30 (test_bitcoin+0x1e3a63)
    #18 boost::execution_monitor::catch_signals(boost::function<int ()> const&) /usr/include/boost/test/impl/execution_monitor.ipp:903:16 (test_bitcoin+0x1e3a63)
    #19 boost::execution_monitor::execute(boost::function<int ()> const&) /usr/include/boost/test/impl/execution_monitor.ipp:1301:16 (test_bitcoin+0x1e3e1a) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #20 boost::execution_monitor::vexecute(boost::function<void ()> const&) /usr/include/boost/test/impl/execution_monitor.ipp:1397:5 (test_bitcoin+0x1df504) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #21 boost::unit_test::unit_test_monitor_t::execute_and_translate(boost::function<void ()> const&, unsigned long) /usr/include/boost/test/impl/unit_test_monitor.ipp:49:9 (test_bitcoin+0x1df504)
    #22 boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /usr/include/boost/test/impl/framework.ipp:815:44 (test_bitcoin+0x217c0e) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #23 boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /usr/include/boost/test/impl/framework.ipp:740:54 (test_bitcoin+0x217e20) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #24 boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /usr/include/boost/test/impl/framework.ipp:740:54 (test_bitcoin+0x217e20) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #25 boost::unit_test::framework::run(unsigned long, bool) /usr/include/boost/test/impl/framework.ipp:1722:29 (test_bitcoin+0x1de218) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #26 boost::unit_test::unit_test_main(boost::unit_test::test_suite* (*)(int, char**), int, char**) /usr/include/boost/test/impl/unit_test_main.ipp:250:9 (test_bitcoin+0x1fbd28) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #27 main /usr/include/boost/test/impl/unit_test_main.ipp:306:12 (test_bitcoin+0x1fc2c3) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
  Mutex M0 (0x7fff581e2118) created at:
    #0 pthread_mutex_lock <null> (test_bitcoin+0x13da7b) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #1 __gthread_mutex_lock(pthread_mutex_t*) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12/bits/gthr-default.h:749:12 (test_bitcoin+0xd87e9b) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #2 __gthread_recursive_mutex_lock(pthread_mutex_t*) /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/x86_64-linux-gnu/c++/12/bits/gthr-default.h:811:10 (test_bitcoin+0xd87e9b)
    #3 std::recursive_mutex::lock() /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/mutex:108:17 (test_bitcoin+0xd87e9b)
    #4 std::unique_lock<std::recursive_mutex>::lock() /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/unique_lock.h:139:17 (test_bitcoin+0xd87e9b)
    #5 UniqueLock<AnnotatedMixin<std::recursive_mutex>>::Enter(char const*, char const*, int) src/./sync.h:164:15 (test_bitcoin+0xd87e9b)
    #6 UniqueLock<AnnotatedMixin<std::recursive_mutex>>::UniqueLock(AnnotatedMixin<std::recursive_mutex>&, char const*, char const*, int, bool) src/./sync.h:183:13 (test_bitcoin+0xd87e9b)
    #7 wallet::CWallet::LoadWallet() src/wallet/wallet.cpp:2350:5 (test_bitcoin+0xd87e9b)
    #8 wallet::WalletTestingSetup::WalletTestingSetup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) src/wallet/test/wallet_test_fixture.cpp:15:14 (test_bitcoin+0x268bbc) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #9 wallet::wallet_tests::ComputeTimeSmart::ComputeTimeSmart() src/wallet/test/wallet_tests.cpp:407:1 (test_bitcoin+0xb6423d) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #10 wallet::wallet_tests::ComputeTimeSmart_invoker() src/wallet/test/wallet_tests.cpp:407:1 (test_bitcoin+0xb6423d)
    #11 boost::detail::function::void_function_invoker0<void (*)(), void>::invoke(boost::detail::function::function_buffer&) /usr/include/boost/function/function_template.hpp:117:11 (test_bitcoin+0x2edd5d) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #12 boost::function0<void>::operator()() const /usr/include/boost/function/function_template.hpp:763:14 (test_bitcoin+0x2629e8) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #13 boost::detail::forward::operator()() /usr/include/boost/test/impl/execution_monitor.ipp:1388:32 (test_bitcoin+0x2629e8)
    #14 boost::detail::function::function_obj_invoker0<boost::detail::forward, int>::invoke(boost::detail::function::function_buffer&) /usr/include/boost/function/function_template.hpp:137:18 (test_bitcoin+0x2629e8)
    #15 boost::function0<int>::operator()() const /usr/include/boost/function/function_template.hpp:763:14 (test_bitcoin+0x1e3a63) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #16 int boost::detail::do_invoke<boost::shared_ptr<boost::detail::translator_holder_base>, boost::function<int ()>>(boost::shared_ptr<boost::detail::translator_holder_base> const&, boost::function<int ()> const&) /usr/include/boost/test/impl/execution_monitor.ipp:301:30 (test_bitcoin+0x1e3a63)
    #17 boost::execution_monitor::catch_signals(boost::function<int ()> const&) /usr/include/boost/test/impl/execution_monitor.ipp:903:16 (test_bitcoin+0x1e3a63)
    #18 boost::execution_monitor::execute(boost::function<int ()> const&) /usr/include/boost/test/impl/execution_monitor.ipp:1301:16 (test_bitcoin+0x1e3e1a) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #19 boost::execution_monitor::vexecute(boost::function<void ()> const&) /usr/include/boost/test/impl/execution_monitor.ipp:1397:5 (test_bitcoin+0x1df504) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #20 boost::unit_test::unit_test_monitor_t::execute_and_translate(boost::function<void ()> const&, unsigned long) /usr/include/boost/test/impl/unit_test_monitor.ipp:49:9 (test_bitcoin+0x1df504)
    #21 boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /usr/include/boost/test/impl/framework.ipp:815:44 (test_bitcoin+0x217c0e) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #22 boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /usr/include/boost/test/impl/framework.ipp:740:54 (test_bitcoin+0x217e20) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #23 boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /usr/include/boost/test/impl/framework.ipp:740:54 (test_bitcoin+0x217e20) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #24 boost::unit_test::framework::run(unsigned long, bool) /usr/include/boost/test/impl/framework.ipp:1722:29 (test_bitcoin+0x1de218) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #25 boost::unit_test::unit_test_main(boost::unit_test::test_suite* (*)(int, char**), int, char**) /usr/include/boost/test/impl/unit_test_main.ipp:250:9 (test_bitcoin+0x1fbd28) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #26 main /usr/include/boost/test/impl/unit_test_main.ipp:306:12 (test_bitcoin+0x1fc2c3) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
  Thread T19 'b-scheduler' (tid=31659, running) created by main thread at:
    #0 pthread_create <null> (test_bitcoin+0x13bdeb) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #1 std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State>>, void (*)()) <null> (libstdc++.so.6+0xdc548) (BuildId: d8f370a6195f115a4e221070f20de2c68d281b66)
    #2 TestingSetup::TestingSetup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::vector<char const*, std::allocator<char const*>> const&, bool, bool) src/test/util/setup_common.cpp:243:7 (test_bitcoin+0xc178bf) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #3 wallet::WalletTestingSetup::WalletTestingSetup(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&) src/wallet/test/wallet_test_fixture.cpp:11:7 (test_bitcoin+0x268a3f) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #4 wallet::wallet_tests::WatchOnlyPubKeys::WatchOnlyPubKeys() src/wallet/test/wallet_tests.cpp:491:1 (test_bitcoin+0xb67bbd) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #5 wallet::wallet_tests::WatchOnlyPubKeys_invoker() src/wallet/test/wallet_tests.cpp:491:1 (test_bitcoin+0xb67bbd)
    #6 boost::detail::function::void_function_invoker0<void (*)(), void>::invoke(boost::detail::function::function_buffer&) /usr/include/boost/function/function_template.hpp:117:11 (test_bitcoin+0x2edd5d) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #7 boost::function0<void>::operator()() const /usr/include/boost/function/function_template.hpp:763:14 (test_bitcoin+0x2629e8) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #8 boost::detail::forward::operator()() /usr/include/boost/test/impl/execution_monitor.ipp:1388:32 (test_bitcoin+0x2629e8)
    #9 boost::detail::function::function_obj_invoker0<boost::detail::forward, int>::invoke(boost::detail::function::function_buffer&) /usr/include/boost/function/function_template.hpp:137:18 (test_bitcoin+0x2629e8)
    #10 boost::function0<int>::operator()() const /usr/include/boost/function/function_template.hpp:763:14 (test_bitcoin+0x1e3a63) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #11 int boost::detail::do_invoke<boost::shared_ptr<boost::detail::translator_holder_base>, boost::function<int ()>>(boost::shared_ptr<boost::detail::translator_holder_base> const&, boost::function<int ()> const&) /usr/include/boost/test/impl/execution_monitor.ipp:301:30 (test_bitcoin+0x1e3a63)
    #12 boost::execution_monitor::catch_signals(boost::function<int ()> const&) /usr/include/boost/test/impl/execution_monitor.ipp:903:16 (test_bitcoin+0x1e3a63)
    #13 boost::execution_monitor::execute(boost::function<int ()> const&) /usr/include/boost/test/impl/execution_monitor.ipp:1301:16 (test_bitcoin+0x1e3e1a) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #14 boost::execution_monitor::vexecute(boost::function<void ()> const&) /usr/include/boost/test/impl/execution_monitor.ipp:1397:5 (test_bitcoin+0x1df504) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #15 boost::unit_test::unit_test_monitor_t::execute_and_translate(boost::function<void ()> const&, unsigned long) /usr/include/boost/test/impl/unit_test_monitor.ipp:49:9 (test_bitcoin+0x1df504)
    #16 boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /usr/include/boost/test/impl/framework.ipp:815:44 (test_bitcoin+0x217c0e) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #17 boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /usr/include/boost/test/impl/framework.ipp:740:54 (test_bitcoin+0x217e20) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #18 boost::unit_test::framework::state::execute_test_tree(unsigned long, unsigned long, boost::unit_test::framework::state::random_generator_helper const*) /usr/include/boost/test/impl/framework.ipp:740:54 (test_bitcoin+0x217e20) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #19 boost::unit_test::framework::run(unsigned long, bool) /usr/include/boost/test/impl/framework.ipp:1722:29 (test_bitcoin+0x1de218) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #20 boost::unit_test::unit_test_main(boost::unit_test::test_suite* (*)(int, char**), int, char**) /usr/include/boost/test/impl/unit_test_main.ipp:250:9 (test_bitcoin+0x1fbd28) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
    #21 main /usr/include/boost/test/impl/unit_test_main.ipp:306:12 (test_bitcoin+0x1fc2c3) (BuildId: 6e7a01ec663618406e731a1fbcd28edb47544ffe)
SUMMARY: ThreadSanitizer: data race /usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/unique_ptr.h:191:51 in std::__uniq_ptr_impl<wallet::ScriptPubKeyMan, std::default_delete<wallet::ScriptPubKeyMan>>::_M_ptr() const
==================
make[3]: *** [Makefile:21823: wallet/test/wallet_tests.cpp.test] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: Leaving directory '/tmp/cirrus-ci-build/bitcoin-core/src'
make[2]: *** [Makefile:19828: check-am] Error 2
make[2]: Leaving directory '/tmp/cirrus-ci-build/bitcoin-core/src'
make[1]: *** [Makefile:19493: check-recursive] Error 1
make[1]: Leaving directory '/tmp/cirrus-ci-build/bitcoin-core/src'
make: *** [Makefile:816: check-recursive] Error 1
```

### How did you obtain Bitcoin Core

Compiled from source

### What version of Bitcoin Core are you using?

current master

### Operating system and version

debian:experimental

### Machine specifications

clang-16, lib/gcc-12