Steps to reproduce on a fresh fedora install:
- Build with thread sanitizer:
0dnf install git vim htop clang libtool make autoconf automake libevent-devel boost-devel python3 -y && git clone https://github.com/bitcoin/bitcoin bitcoin-core && cd bitcoin-core && ./autogen.sh && ./configure --disable-wallet --with-sanitizers=thread --with-gui=no --disable-tests CC=clang CXX=clang++ && make
- Run bitcoin core:
0TSAN_OPTIONS="halt_on_error=1" ./src/bitcoind -noprinttoconsole
1==================
2WARNING: ThreadSanitizer: double lock of a mutex (pid=14344)
3 [#0](/bitcoin-bitcoin/0/) pthread_mutex_lock ??:? (bitcoind+0x15820b)
4 [#1](/bitcoin-bitcoin/1/) __gthread_mutex_lock(pthread_mutex_t*) /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux/bits/gthr-default.h:749 (bitcoind+0x624528)
5 [#2](/bitcoin-bitcoin/2/) std::mutex::lock() /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/std_mutex.h:100 (bitcoind+0x624528)
6 [#3](/bitcoin-bitcoin/3/) std::unique_lock<std::mutex>::lock() /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/unique_lock.h:138 (bitcoind+0x624528)
7 [#4](/bitcoin-bitcoin/4/) UniqueLock<AnnotatedMixin<std::mutex>, std::unique_lock<std::mutex> >::Enter(char const*, char const*, int) /bitcoin-core/src/./sync.h:131 (bitcoind+0x624528)
8 [#5](/bitcoin-bitcoin/5/) UniqueLock /bitcoin-core/src/./sync.h:152 (bitcoind+0x624528)
9 [#6](/bitcoin-bitcoin/6/) CThreadInterrupt::sleep_for(std::chrono::duration<long, std::ratio<1l, 1000l> >) /bitcoin-core/src/threadinterrupt.cpp:33 (bitcoind+0x624528)
10 [#7](/bitcoin-bitcoin/7/) CThreadInterrupt::sleep_for(std::chrono::duration<long, std::ratio<1l, 1l> >) /bitcoin-core/src/threadinterrupt.cpp:39 (bitcoind+0x62467f)
11 [#8](/bitcoin-bitcoin/8/) CConnman::ThreadOpenAddedConnections() /bitcoin-core/src/net.cpp:1973 (bitcoind+0x2470dc)
12 [#9](/bitcoin-bitcoin/9/) void std::__invoke_impl<void, void (CConnman::*&)(), CConnman*&>(std::__invoke_memfun_deref, void (CConnman::*&)(), CConnman*&) /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/invoke.h:73 (bitcoind+0x260e8c)
13 [#10](/bitcoin-bitcoin/10/) std::__invoke_result<void (CConnman::*&)(), CConnman*&>::type std::__invoke<void (CConnman::*&)(), CConnman*&>(void (CConnman::*&)(), CConnman*&) /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/invoke.h:95 (bitcoind+0x260e8c)
14 [#11](/bitcoin-bitcoin/11/) void std::_Bind<void (CConnman::*(CConnman*))()>::__call<void, , 0ul>(std::tuple<>&&, std::_Index_tuple<0ul>) /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/functional:416 (bitcoind+0x260e8c)
15 [#12](/bitcoin-bitcoin/12/) void std::_Bind<void (CConnman::*(CConnman*))()>::operator()<, void>() /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/functional:499 (bitcoind+0x260e8c)
16 [#13](/bitcoin-bitcoin/13/) void std::__invoke_impl<void, std::_Bind<void (CConnman::*(CConnman*))()>&>(std::__invoke_other, std::_Bind<void (CConnman::*(CConnman*))()>&) /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/invoke.h:60 (bitcoind+0x260e8c)
17 [#14](/bitcoin-bitcoin/14/) _ZSt10__invoke_rIvRSt5_BindIFM8CConnmanFvvEPS1_EEJEENSt9enable_ifIXsr6__and_ISt7is_voidIT_ESt14__is_invocableIT0_JDpT1_EEEE5valueESA_E4typeEOSD_DpOSE_ /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/invoke.h:153 (bitcoind+0x260e8c)
18 [#15](/bitcoin-bitcoin/15/) std::_Function_handler<void (), std::_Bind<void (CConnman::*(CConnman*))()> >::_M_invoke(std::_Any_data const&) /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/std_function.h:291 (bitcoind+0x260e8c)
19 [#16](/bitcoin-bitcoin/16/) std::function<void ()>::operator()() const /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/std_function.h:622 (bitcoind+0x20c1cf)
20 [#17](/bitcoin-bitcoin/17/) void TraceThread<std::function<void ()> >(char const*, std::function<void ()>) /bitcoin-core/src/./util/system.h:392 (bitcoind+0x20c1cf)
21 [#18](/bitcoin-bitcoin/18/) void std::__invoke_impl<void, void (*)(char const*, std::function<void ()>), char const*, std::function<void ()> >(std::__invoke_other, void (*&&)(char const*, std::function<void ()>), char const*&&, std::function<void ()>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/invoke.h:60 (bitcoind+0x261173)
22 [#19](/bitcoin-bitcoin/19/) std::__invoke_result<void (*)(char const*, std::function<void ()>), char const*, std::function<void ()> >::type std::__invoke<void (*)(char const*, std::function<void ()>), char const*, std::function<void ()> >(void (*&&)(char const*, std::function<void ()>), char const*&&, std::function<void ()>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/invoke.h:95 (bitcoind+0x261173)
23 [#20](/bitcoin-bitcoin/20/) void std::thread::_Invoker<std::tuple<void (*)(char const*, std::function<void ()>), char const*, std::function<void ()> > >::_M_invoke<0ul, 1ul, 2ul>(std::_Index_tuple<0ul, 1ul, 2ul>) /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/thread:264 (bitcoind+0x261173)
24 [#21](/bitcoin-bitcoin/21/) std::thread::_Invoker<std::tuple<void (*)(char const*, std::function<void ()>), char const*, std::function<void ()> > >::operator()() /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/thread:271 (bitcoind+0x261173)
25 [#22](/bitcoin-bitcoin/22/) std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(char const*, std::function<void ()>), char const*, std::function<void ()> > > >::_M_run() /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/thread:215 (bitcoind+0x261173)
26 [#23](/bitcoin-bitcoin/23/) std::error_code::default_error_condition() const ??:? (libstdc++.so.6+0xd8a93)
27
28 Location is heap block of size 328976 at 0x7fe8431aa000 allocated by main thread:
29 [#0](/bitcoin-bitcoin/0/) operator new(unsigned long) ??:? (bitcoind+0x1d495c)
30 [#1](/bitcoin-bitcoin/1/) AppInitMain(NodeContext&) /bitcoin-core/src/init.cpp:1376 (bitcoind+0x1f8d85)
31 [#2](/bitcoin-bitcoin/2/) AppInit(int, char**) /bitcoin-core/src/bitcoind.cpp:148 (bitcoind+0x1d6df6)
32 [#3](/bitcoin-bitcoin/3/) main /bitcoin-core/src/bitcoind.cpp:178 (bitcoind+0x1d6df6)
33
34 Mutex M131496 (0x7fe8431fa4a8) created at:
35 [#0](/bitcoin-bitcoin/0/) pthread_mutex_lock ??:? (bitcoind+0x15820b)
36 [#1](/bitcoin-bitcoin/1/) __gthread_mutex_lock(pthread_mutex_t*) /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/x86_64-redhat-linux/bits/gthr-default.h:749 (bitcoind+0x624528)
37 [#2](/bitcoin-bitcoin/2/) std::mutex::lock() /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/std_mutex.h:100 (bitcoind+0x624528)
38 [#3](/bitcoin-bitcoin/3/) std::unique_lock<std::mutex>::lock() /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/unique_lock.h:138 (bitcoind+0x624528)
39 [#4](/bitcoin-bitcoin/4/) UniqueLock<AnnotatedMixin<std::mutex>, std::unique_lock<std::mutex> >::Enter(char const*, char const*, int) /bitcoin-core/src/./sync.h:131 (bitcoind+0x624528)
40 [#5](/bitcoin-bitcoin/5/) UniqueLock /bitcoin-core/src/./sync.h:152 (bitcoind+0x624528)
41 [#6](/bitcoin-bitcoin/6/) CThreadInterrupt::sleep_for(std::chrono::duration<long, std::ratio<1l, 1000l> >) /bitcoin-core/src/threadinterrupt.cpp:33 (bitcoind+0x624528)
42 [#7](/bitcoin-bitcoin/7/) CThreadInterrupt::sleep_for(std::chrono::duration<long, std::ratio<1l, 1l> >) /bitcoin-core/src/threadinterrupt.cpp:39 (bitcoind+0x62467f)
43 [#8](/bitcoin-bitcoin/8/) CConnman::ThreadDNSAddressSeed() /bitcoin-core/src/net.cpp:1598 (bitcoind+0x242488)
44 [#9](/bitcoin-bitcoin/9/) void std::__invoke_impl<void, void (CConnman::*&)(), CConnman*&>(std::__invoke_memfun_deref, void (CConnman::*&)(), CConnman*&) /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/invoke.h:73 (bitcoind+0x260e8c)
45 [#10](/bitcoin-bitcoin/10/) std::__invoke_result<void (CConnman::*&)(), CConnman*&>::type std::__invoke<void (CConnman::*&)(), CConnman*&>(void (CConnman::*&)(), CConnman*&) /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/invoke.h:95 (bitcoind+0x260e8c)
46 [#11](/bitcoin-bitcoin/11/) void std::_Bind<void (CConnman::*(CConnman*))()>::__call<void, , 0ul>(std::tuple<>&&, std::_Index_tuple<0ul>) /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/functional:416 (bitcoind+0x260e8c)
47 [#12](/bitcoin-bitcoin/12/) void std::_Bind<void (CConnman::*(CConnman*))()>::operator()<, void>() /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/functional:499 (bitcoind+0x260e8c)
48 [#13](/bitcoin-bitcoin/13/) void std::__invoke_impl<void, std::_Bind<void (CConnman::*(CConnman*))()>&>(std::__invoke_other, std::_Bind<void (CConnman::*(CConnman*))()>&) /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/invoke.h:60 (bitcoind+0x260e8c)
49 [#14](/bitcoin-bitcoin/14/) _ZSt10__invoke_rIvRSt5_BindIFM8CConnmanFvvEPS1_EEJEENSt9enable_ifIXsr6__and_ISt7is_voidIT_ESt14__is_invocableIT0_JDpT1_EEEE5valueESA_E4typeEOSD_DpOSE_ /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/invoke.h:153 (bitcoind+0x260e8c)
50 [#15](/bitcoin-bitcoin/15/) std::_Function_handler<void (), std::_Bind<void (CConnman::*(CConnman*))()> >::_M_invoke(std::_Any_data const&) /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/std_function.h:291 (bitcoind+0x260e8c)
51 [#16](/bitcoin-bitcoin/16/) std::function<void ()>::operator()() const /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/std_function.h:622 (bitcoind+0x20c1cf)
52 [#17](/bitcoin-bitcoin/17/) void TraceThread<std::function<void ()> >(char const*, std::function<void ()>) /bitcoin-core/src/./util/system.h:392 (bitcoind+0x20c1cf)
53 [#18](/bitcoin-bitcoin/18/) void std::__invoke_impl<void, void (*)(char const*, std::function<void ()>), char const*, std::function<void ()> >(std::__invoke_other, void (*&&)(char const*, std::function<void ()>), char const*&&, std::function<void ()>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/invoke.h:60 (bitcoind+0x261173)
54 [#19](/bitcoin-bitcoin/19/) std::__invoke_result<void (*)(char const*, std::function<void ()>), char const*, std::function<void ()> >::type std::__invoke<void (*)(char const*, std::function<void ()>), char const*, std::function<void ()> >(void (*&&)(char const*, std::function<void ()>), char const*&&, std::function<void ()>&&) /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/bits/invoke.h:95 (bitcoind+0x261173)
55 [#20](/bitcoin-bitcoin/20/) void std::thread::_Invoker<std::tuple<void (*)(char const*, std::function<void ()>), char const*, std::function<void ()> > >::_M_invoke<0ul, 1ul, 2ul>(std::_Index_tuple<0ul, 1ul, 2ul>) /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/thread:264 (bitcoind+0x261173)
56 [#21](/bitcoin-bitcoin/21/) std::thread::_Invoker<std::tuple<void (*)(char const*, std::function<void ()>), char const*, std::function<void ()> > >::operator()() /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/thread:271 (bitcoind+0x261173)
57 [#22](/bitcoin-bitcoin/22/) std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(char const*, std::function<void ()>), char const*, std::function<void ()> > > >::_M_run() /usr/bin/../lib/gcc/x86_64-redhat-linux/10/../../../../include/c++/10/thread:215 (bitcoind+0x261173)
58 [#23](/bitcoin-bitcoin/23/) std::error_code::default_error_condition() const ??:? (libstdc++.so.6+0xd8a93)
59
60SUMMARY: ThreadSanitizer: double lock of a mutex ??:? in pthread_mutex_lock
61==================