UB: double lock of mutex in init.cpp #19024

issue MarcoFalke openend this issue on May 19, 2020
  1. MarcoFalke commented at 11:46 pm on May 19, 2020: member

    Steps to reproduce on a fresh fedora install:

    1. 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
    
    1. 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==================
    
  2. MarcoFalke added the label Bug on May 19, 2020
  3. MarcoFalke commented at 11:47 pm on May 19, 2020: member
    I am wondering why the tread sanitizer on Ubuntu does not detect this issue
  4. hebasto commented at 11:48 am on May 20, 2020: member

    Confirm:

    • Fedora 32, Clang 10.0.0: WARNING: ThreadSanitizer: double lock of a mutex
    • Ubuntu 20.04, Clang 10.0.0: no warnings
  5. hebasto commented at 3:50 pm on May 20, 2020: member
    @MarcoFalke Mind testing #19029?
  6. MarcoFalke commented at 8:04 pm on May 20, 2020: member
    Same bug in debian, so I guess this should be reported to the debian clang maintainer?
  7. hebasto commented at 4:06 am on May 21, 2020: member

    llvm-project-10.0.0/compiler-rt/test/tsan/mutex_double_lock.cpp:

     0// RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s
     1#include <pthread.h>
     2#include <unistd.h>
     3
     4extern "C" void AnnotateRWLockAcquired(const char *f, int l, void *m, long rw);
     5
     6void *ThreadFunc(void *m) {
     7  AnnotateRWLockAcquired(__FILE__, __LINE__, m, 1);
     8  return 0;
     9}
    10
    11int main() {
    12  int m = 0;
    13  AnnotateRWLockAcquired(__FILE__, __LINE__, &m, 1);
    14  pthread_t th;
    15  pthread_create(&th, 0, ThreadFunc, &m);
    16  pthread_join(th, 0);
    17  return 0;
    18}
    19
    20// CHECK: WARNING: ThreadSanitizer: double lock of a mutex
    21// CHECK:     [#0](/bitcoin-bitcoin/0/) AnnotateRWLockAcquired
    22// CHECK:     [#1](/bitcoin-bitcoin/1/) ThreadFunc
    23// CHECK: Location is stack of main thread.
    24// CHECK:   Mutex {{.*}} created at:
    25// CHECK:     [#0](/bitcoin-bitcoin/0/) AnnotateRWLockAcquired
    26// CHECK:     [#1](/bitcoin-bitcoin/1/) main
    27// CHECK: SUMMARY: ThreadSanitizer: double lock of a mutex {{.*}}mutex_double_lock.cpp{{.*}}ThreadFunc
    
  8. hebasto commented at 7:38 am on May 21, 2020: member

    Same bug in debian, so I guess this should be reported to the debian clang maintainer?

    I cannot see such warnings on macOS 10.15 with brewed clang 10.0.0. Maybe it is Fedora distro’s bug?

    The (almost) minimal code for testing:

     0#include <condition_variable>
     1#include <chrono>
     2#include <iostream>
     3#include <mutex>
     4#include <thread>
     5 
     6std::mutex m;
     7std::condition_variable cv;
     8
     9void ThreadOne() {
    10    std::unique_lock<std::mutex> lock(m);
    11    std::cout << __func__ << ":" << __LINE__ << std::endl;
    12    cv.wait_for(lock, std::chrono::seconds(3), []{ return false; });
    13    std::cout << __func__ << ":" << __LINE__ << std::endl;
    14}
    15
    16void ThreadTwo() {
    17    std::unique_lock<std::mutex> lock(m);
    18    std::cout << __func__ << ":" << __LINE__ << std::endl;
    19    cv.wait_for(lock, std::chrono::seconds(10), []{ return false; });
    20    std::cout << __func__ << ":" << __LINE__ << std::endl;
    21}
    22
    23int main() {
    24    std::thread t1(ThreadOne);
    25    std::thread t2(ThreadTwo);
    26    t1.join();
    27    t2.join();
    28    return 0;
    29}
    
  9. elichai commented at 8:05 am on May 21, 2020: contributor

    I see this on Arch with self compiled clang ( clang version 10.0.0 (https://github.com/llvm/llvm-project.git d32170dbd5b0d54436537b6b75beaf44324e0c28) )

     0$ TSAN_OPTIONS="halt_on_error=1" ./src/bitcoind -noprinttoconsole
     1==================
     2WARNING: ThreadSanitizer: double lock of a mutex (pid=105686)
     3    [#0](/bitcoin-bitcoin/0/) pthread_mutex_lock /home/elichai2/gits/llvm-project/compiler-rt/lib/tsan/../sanitizer_common/sanitizer_common_interceptors.inc:4153:3 (bitcoind+0xa0316)
     4    [#1](/bitcoin-bitcoin/1/) __gthread_mutex_lock /usr/include/c++/10.1.0/x86_64-pc-linux-gnu/bits/gthr-default.h:749:41 (bitcoind+0x536b0f)
     5    [#2](/bitcoin-bitcoin/2/) std::mutex::lock() /usr/include/c++/10.1.0/bits/std_mutex.h:100:37 (bitcoind+0x536b0f)
     6    [#3](/bitcoin-bitcoin/3/) std::unique_lock<std::mutex>::lock() /usr/include/c++/10.1.0/bits/unique_lock.h:138:21 (bitcoind+0x536b0f)
     7    [#4](/bitcoin-bitcoin/4/) UniqueLock<AnnotatedMixin<std::mutex>, std::unique_lock<std::mutex> >::Enter(char const*, char const*, int) /home/elichai2/gits/bitcoin-variant/src/./sync.h:131:23 (bitcoind+0x536b0f)
     8    [#5](/bitcoin-bitcoin/5/) UniqueLock<AnnotatedMixin<std::mutex>, std::unique_lock<std::mutex> >::UniqueLock(AnnotatedMixin<std::mutex>&, char const*, char const*, int, bool) /home/elichai2/gits/bitcoin-variant/src/./sync.h:152:18 (bitcoind+0x536b0f)
     9    [#6](/bitcoin-bitcoin/6/) CThreadInterrupt::sleep_for(std::chrono::duration<long, std::ratio<1l, 1000l> >) /home/elichai2/gits/bitcoin-variant/src/threadinterrupt.cpp:33:5 (bitcoind+0x536b0f)
    10    [#7](/bitcoin-bitcoin/7/) void std::__invoke_impl<void, void (CConnman::*&)(), CConnman*&>(std::__invoke_memfun_deref, void (CConnman::*&)(), CConnman*&) /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/bits/invoke.h:73:14 (bitcoind+0x17d5ac)
    11    [#8](/bitcoin-bitcoin/8/) std::__invoke_result<void (CConnman::*&)(), CConnman*&>::type std::__invoke<void (CConnman::*&)(), CConnman*&>(void (CConnman::*&)(), CConnman*&) /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/bits/invoke.h:95:14 (bitcoind+0x17d5ac)
    12    [#9](/bitcoin-bitcoin/9/) void std::_Bind<void (CConnman::* (CConnman*))()>::__call<void, 0ul>(std::tuple<>&&, std::_Index_tuple<0ul>) /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/functional:416:11 (bitcoind+0x17d5ac)
    13    [#10](/bitcoin-bitcoin/10/) void std::_Bind<void (CConnman::* (CConnman*))()>::operator()<void>() /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/functional:499:17 (bitcoind+0x17d5ac)
    14    [#11](/bitcoin-bitcoin/11/) void std::__invoke_impl<void, std::_Bind<void (CConnman::* (CConnman*))()>&>(std::__invoke_other, std::_Bind<void (CConnman::* (CConnman*))()>&) /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/bits/invoke.h:60:14 (bitcoind+0x17d5ac)
    15    [#12](/bitcoin-bitcoin/12/) std::enable_if<__and_<std::is_void<void>, std::__is_invocable<std::_Bind<void (CConnman::* (CConnman*))()>&> >::value, void>::type std::__invoke_r<void, std::_Bind<void (CConnman::* (CConnman*))()>&>(std::_Bind<void (CConnman::* (CConnman*))()>&) /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/bits/invoke.h:153:7 (bitcoind+0x17d5ac)
    16    [#13](/bitcoin-bitcoin/13/) std::_Function_handler<void (), std::_Bind<void (CConnman::* (CConnman*))()> >::_M_invoke(std::_Any_data const&) /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/bits/std_function.h:291:9 (bitcoind+0x17d5ac)
    17    [#14](/bitcoin-bitcoin/14/) std::function<void ()>::operator()() const /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/bits/std_function.h:622:14 (bitcoind+0x12979f)
    18    [#15](/bitcoin-bitcoin/15/) void TraceThread<std::function<void ()> >(char const*, std::function<void ()>) /home/elichai2/gits/bitcoin-variant/src/./util/system.h:392:9 (bitcoind+0x12979f)
    19    [#16](/bitcoin-bitcoin/16/) 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/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/bits/invoke.h:60:14 (bitcoind+0x17d893)
    20    [#17](/bitcoin-bitcoin/17/) 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/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/bits/invoke.h:95:14 (bitcoind+0x17d893)
    21    [#18](/bitcoin-bitcoin/18/) 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/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/thread:264:13 (bitcoind+0x17d893)
    22    [#19](/bitcoin-bitcoin/19/) std::thread::_Invoker<std::tuple<void (*)(char const*, std::function<void ()>), char const*, std::function<void ()> > >::operator()() /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/thread:271:11 (bitcoind+0x17d893)
    23    [#20](/bitcoin-bitcoin/20/) std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(char const*, std::function<void ()>), char const*, std::function<void ()> > > >::_M_run() /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/thread:215:13 (bitcoind+0x17d893)
    24    [#21](/bitcoin-bitcoin/21/) execute_native_thread_routine /build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:80:18 (libstdc++.so.6+0xcfb73)
    25
    26  Location is heap block of size 328976 at 0x7fd09f302000 allocated by main thread:
    27    [#0](/bitcoin-bitcoin/0/) operator new(unsigned long) /home/elichai2/gits/llvm-project/compiler-rt/lib/tsan/rtl/tsan_new_delete.cpp:64:3 (bitcoind+0xf231b)
    28    [#1](/bitcoin-bitcoin/1/) AppInitMain(NodeContext&) /home/elichai2/gits/bitcoin-variant/src/init.cpp:1376:46 (bitcoind+0x116388)
    29    [#2](/bitcoin-bitcoin/2/) AppInit(int, char**) /home/elichai2/gits/bitcoin-variant/src/bitcoind.cpp:148:16 (bitcoind+0xf3f16)
    30    [#3](/bitcoin-bitcoin/3/) main /home/elichai2/gits/bitcoin-variant/src/bitcoind.cpp:178:13 (bitcoind+0xf3f16)
    31
    32  Mutex M921689607751673000 is already destroyed.
    33
    34SUMMARY: ThreadSanitizer: double lock of a mutex /usr/include/c++/10.1.0/x86_64-pc-linux-gnu/bits/gthr-default.h:749:41 in __gthread_mutex_lock
    
  10. hebasto commented at 8:07 am on May 21, 2020: member
    @elichai Does #19029 fix it for you?
  11. elichai commented at 8:15 am on May 21, 2020: contributor

    Nope, still the same error: (tried make clean and all)

     0$ git checkout origin/pr/19029
     1$ ./autogen.sh && ./configure --disable-wallet --with-sanitizers=thread --with-gui=no --disable-tests CC=clang CXX=clang++
     2$ make clean
     3$ make -j12
     4$ with-env [TSAN_OPTIONS "halt_on_error=1"] {./src/bitcoind -noprinttoconsole}
     5==================
     6WARNING: ThreadSanitizer: double lock of a mutex (pid=141560)
     7    [#0](/bitcoin-bitcoin/0/) pthread_mutex_lock /home/elichai2/gits/llvm-project/compiler-rt/lib/tsan/../sanitizer_common/sanitizer_common_interceptors.inc:4153:3 (bitcoind+0x9d696)
     8    [#1](/bitcoin-bitcoin/1/) __gthread_mutex_lock(pthread_mutex_t*) /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/x86_64-pc-linux-gnu/bits/gthr-default.h:749:12 (bitcoind+0x158b35)
     9    [#2](/bitcoin-bitcoin/2/) std::mutex::lock() /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/bits/std_mutex.h:100:17 (bitcoind+0x158b35)
    10    [#3](/bitcoin-bitcoin/3/) std::lock_guard<std::mutex>::lock_guard(std::mutex&) /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/bits/std_mutex.h:159:19 (bitcoind+0x158b35)
    11    [#4](/bitcoin-bitcoin/4/) CConnman::WakeMessageHandler() /home/elichai2/gits/bitcoin-variant/src/net.cpp:1458:37 (bitcoind+0x158b35)
    12    [#5](/bitcoin-bitcoin/5/) CConnman::SocketHandler() /home/elichai2/gits/bitcoin-variant/src/net.cpp:1399:21 (bitcoind+0x158b35)
    13    [#6](/bitcoin-bitcoin/6/) CConnman::ThreadSocketHandler() /home/elichai2/gits/bitcoin-variant/src/net.cpp:1451:9 (bitcoind+0x159c4c)
    14    [#7](/bitcoin-bitcoin/7/) void std::__invoke_impl<void, void (CConnman::*&)(), CConnman*&>(std::__invoke_memfun_deref, void (CConnman::*&)(), CConnman*&) /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/bits/invoke.h:73:14 (bitcoind+0x17a9dc)
    15    [#8](/bitcoin-bitcoin/8/) std::__invoke_result<void (CConnman::*&)(), CConnman*&>::type std::__invoke<void (CConnman::*&)(), CConnman*&>(void (CConnman::*&)(), CConnman*&) /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/bits/invoke.h:95:14 (bitcoind+0x17a9dc)
    16    [#9](/bitcoin-bitcoin/9/) void std::_Bind<void (CConnman::* (CConnman*))()>::__call<void, 0ul>(std::tuple<>&&, std::_Index_tuple<0ul>) /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/functional:416:11 (bitcoind+0x17a9dc)
    17    [#10](/bitcoin-bitcoin/10/) void std::_Bind<void (CConnman::* (CConnman*))()>::operator()<void>() /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/functional:499:17 (bitcoind+0x17a9dc)
    18    [#11](/bitcoin-bitcoin/11/) void std::__invoke_impl<void, std::_Bind<void (CConnman::* (CConnman*))()>&>(std::__invoke_other, std::_Bind<void (CConnman::* (CConnman*))()>&) /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/bits/invoke.h:60:14 (bitcoind+0x17a9dc)
    19    [#12](/bitcoin-bitcoin/12/) std::enable_if<__and_<std::is_void<void>, std::__is_invocable<std::_Bind<void (CConnman::* (CConnman*))()>&> >::value, void>::type std::__invoke_r<void, std::_Bind<void (CConnman::* (CConnman*))()>&>(std::_Bind<void (CConnman::* (CConnman*))()>&) /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/bits/invoke.h:153:7 (bitcoind+0x17a9dc)
    20    [#13](/bitcoin-bitcoin/13/) std::_Function_handler<void (), std::_Bind<void (CConnman::* (CConnman*))()> >::_M_invoke(std::_Any_data const&) /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/bits/std_function.h:291:9 (bitcoind+0x17a9dc)
    21    [#14](/bitcoin-bitcoin/14/) std::function<void ()>::operator()() const /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/bits/std_function.h:622:14 (bitcoind+0x126b1f)
    22    [#15](/bitcoin-bitcoin/15/) void TraceThread<std::function<void ()> >(char const*, std::function<void ()>) /home/elichai2/gits/bitcoin-variant/src/./util/system.h:392:9 (bitcoind+0x126b1f)
    23    [#16](/bitcoin-bitcoin/16/) 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/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/bits/invoke.h:60:14 (bitcoind+0x17acc3)
    24    [#17](/bitcoin-bitcoin/17/) 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/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/bits/invoke.h:95:14 (bitcoind+0x17acc3)
    25    [#18](/bitcoin-bitcoin/18/) 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/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/thread:264:13 (bitcoind+0x17acc3)
    26    [#19](/bitcoin-bitcoin/19/) std::thread::_Invoker<std::tuple<void (*)(char const*, std::function<void ()>), char const*, std::function<void ()> > >::operator()() /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/thread:271:11 (bitcoind+0x17acc3)
    27    [#20](/bitcoin-bitcoin/20/) std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)(char const*, std::function<void ()>), char const*, std::function<void ()> > > >::_M_run() /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/thread:215:13 (bitcoind+0x17acc3)
    28    [#21](/bitcoin-bitcoin/21/) execute_native_thread_routine /build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:80:18 (libstdc++.so.6+0xcfb73)
    29
    30  Location is heap block of size 329168 at 0x7ff638b26000 allocated by main thread:
    31    [#0](/bitcoin-bitcoin/0/) operator new(unsigned long) /home/elichai2/gits/llvm-project/compiler-rt/lib/tsan/rtl/tsan_new_delete.cpp:64:3 (bitcoind+0xef69b)
    32    [#1](/bitcoin-bitcoin/1/) AppInitMain(NodeContext&) /home/elichai2/gits/bitcoin-variant/src/init.cpp:1376:46 (bitcoind+0x113708)
    33    [#2](/bitcoin-bitcoin/2/) AppInit(int, char**) /home/elichai2/gits/bitcoin-variant/src/bitcoind.cpp:148:16 (bitcoind+0xf1296)
    34    [#3](/bitcoin-bitcoin/3/) main /home/elichai2/gits/bitcoin-variant/src/bitcoind.cpp:178:13 (bitcoind+0xf1296)
    35
    36  Mutex M935763518076445768 is already destroyed.
    37
    38SUMMARY: ThreadSanitizer: double lock of a mutex /usr/lib64/gcc/x86_64-pc-linux-gnu/10.1.0/../../../../include/c++/10.1.0/x86_64-pc-linux-gnu/bits/gthr-default.h:749:12 in __gthread_mutex_lock(pthread_mutex_t*)
    39==================
    
  12. hebasto commented at 8:18 am on May 21, 2020: member

    Nope, still the same error: (tried make clean and all)

    … but it differs from the one reported by @MarcoFalke in OP, right?

  13. hebasto commented at 8:21 am on May 21, 2020: member
    Could the TSan behavior depend on libstdc++ implementation?
  14. elichai commented at 8:30 am on May 21, 2020: contributor

    hmm it does say:

    C++11 threading is supported with llvm libc++.

    https://clang.llvm.org/docs/ThreadSanitizer.html#current-status

  15. hebasto commented at 10:00 am on May 21, 2020: member

    @elichai Thanks for the hint :)

    I can reproduce warnings on Ubuntu 20.04 for the test case:

    0$ sudo apt install libc++-dev libc++abi-dev
    1$ clang++ -stdlib=libc++ -pthread -fsanitize=thread -g -O1 -o double-lock double-lock.cpp
    2$ ./double-lock
    

    But I failed to build bitcoind with CXXFLAGS='-stdlib=libc++':

    0/usr/bin/ld: libbitcoin_util.a(libbitcoin_util_a-system.o): in function `SetupEnvironment()':
    1system.cpp:(.text+0xb576): undefined reference to `boost::filesystem::path::imbue(std::__1::locale const&)'
    2/usr/bin/ld: system.cpp:(.text+0xb588): undefined reference to `boost::filesystem::path::imbue(std::__1::locale const&)'
    3clang: error: linker command failed with exit code 1 (use -v to see invocation)
    

    It seems on Fedora 32 the clang++ uses libc++ by default, but I don’t know how to verify this assumption.

  16. elichai commented at 10:02 am on May 21, 2020: contributor
    0/usr/bin/ld: libbitcoin_util.a(libbitcoin_util_a-system.o): in function `SetupEnvironment()':
    1system.cpp:(.text+0xb576): undefined reference to `boost::filesystem::path::imbue(std::__1::locale const&)'
    2/usr/bin/ld: system.cpp:(.text+0xb588): undefined reference to `boost::filesystem::path::imbue(std::__1::locale const&)'
    3clang: error: linker command failed with exit code 1 (use -v to see invocation)
    

    Got the exact same error, but stuff came up so don’t have the time right now to debug this and see why boost fails linking with boost and libc++

  17. hebasto commented at 10:43 am on May 21, 2020: member

    But I failed to build bitcoind with CXXFLAGS='-stdlib=libc++':

    LLVM’s libc++ and GNU’s libstdc++ aren’t ABI compatible.

  18. MarcoFalke commented at 11:34 am on May 21, 2020: member

    Thanks for the minimal example.

    Fedora 32:

     0$ clang++ -fsanitize=thread -lpthread -I/usr/include/c++/10/x86_64-redhat-linux/ /tmp/m.cpp -o /tmp/m.exe && /tmp/m.exe 
     1ThreadOne:12
     2==================
     3WARNING: ThreadSanitizer: double lock of a mutex (pid=2976881)
     4    [#0](/bitcoin-bitcoin/0/) pthread_mutex_lock <null> (m.exe+0x452f1b)
     5    [#1](/bitcoin-bitcoin/1/) __gthread_mutex_lock(pthread_mutex_t*) <null> (m.exe+0x4d15f6)
     6    [#2](/bitcoin-bitcoin/2/) std::mutex::lock() <null> (m.exe+0x4d1d88)
     7    [#3](/bitcoin-bitcoin/3/) std::unique_lock<std::mutex>::lock() <null> (m.exe+0x4d1d13)
     8    [#4](/bitcoin-bitcoin/4/) std::unique_lock<std::mutex>::unique_lock(std::mutex&) <null> (m.exe+0x4d1920)
     9    [#5](/bitcoin-bitcoin/5/) ThreadTwo() <null> (m.exe+0x4d1251)
    10    [#6](/bitcoin-bitcoin/6/) void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void (*&&)()) <null> (m.exe+0x4d35fd)
    11    [#7](/bitcoin-bitcoin/7/) std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void (*&&)()) <null> (m.exe+0x4d3530)
    12    [#8](/bitcoin-bitcoin/8/) void std::thread::_Invoker<std::tuple<void (*)()> >::_M_invoke<0ul>(std::_Index_tuple<0ul>) <null> (m.exe+0x4d34d8)
    13    [#9](/bitcoin-bitcoin/9/) std::thread::_Invoker<std::tuple<void (*)()> >::operator()() <null> (m.exe+0x4d3478)
    14    [#10](/bitcoin-bitcoin/10/) std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> > >::_M_run() <null> (m.exe+0x4d334f)
    15    [#11](/bitcoin-bitcoin/11/) <null> <null> (libstdc++.so.6+0xd8ac3)
    16
    17  Location is global 'm' of size 40 at 0x000000fb7bf0 (m.exe+0x000000fb7bf0)
    18
    19  Mutex M13 (0x000000fb7bf0) created at:
    20    [#0](/bitcoin-bitcoin/0/) pthread_mutex_lock <null> (m.exe+0x452f1b)
    21    [#1](/bitcoin-bitcoin/1/) __gthread_mutex_lock(pthread_mutex_t*) <null> (m.exe+0x4d15f6)
    22    [#2](/bitcoin-bitcoin/2/) std::mutex::lock() <null> (m.exe+0x4d1d88)
    23    [#3](/bitcoin-bitcoin/3/) std::unique_lock<std::mutex>::lock() <null> (m.exe+0x4d1d13)
    24    [#4](/bitcoin-bitcoin/4/) std::unique_lock<std::mutex>::unique_lock(std::mutex&) <null> (m.exe+0x4d1920)
    25    [#5](/bitcoin-bitcoin/5/) ThreadOne() <null> (m.exe+0x4d0fb1)
    26    [#6](/bitcoin-bitcoin/6/) void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void (*&&)()) <null> (m.exe+0x4d35fd)
    27    [#7](/bitcoin-bitcoin/7/) std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void (*&&)()) <null> (m.exe+0x4d3530)
    28    [#8](/bitcoin-bitcoin/8/) void std::thread::_Invoker<std::tuple<void (*)()> >::_M_invoke<0ul>(std::_Index_tuple<0ul>) <null> (m.exe+0x4d34d8)
    29    [#9](/bitcoin-bitcoin/9/) std::thread::_Invoker<std::tuple<void (*)()> >::operator()() <null> (m.exe+0x4d3478)
    30    [#10](/bitcoin-bitcoin/10/) std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> > >::_M_run() <null> (m.exe+0x4d334f)
    31    [#11](/bitcoin-bitcoin/11/) <null> <null> (libstdc++.so.6+0xd8ac3)
    32
    33SUMMARY: ThreadSanitizer: double lock of a mutex (/tmp/m.exe+0x452f1b) in pthread_mutex_lock
    34==================
    35ThreadTwo:19
    36ThreadOne:14
    37ThreadTwo:21
    38ThreadSanitizer: reported 1 warnings
    

    Debian Sid:

    0$ clang++ -fsanitize=thread /tmp/m.cpp -o /tmp/m.exe && /tmp/m.exe
    1ThreadOne:12
    2ThreadTwo:19
    3ThreadOne:14
    4ThreadTwo:21
    

    Arch:

     0$ clang++ -fsanitize=thread /tmp/m.cpp -o /tmp/m.exe && /tmp/m.exe
     1ThreadOne:12
     2==================
     3WARNING: ThreadSanitizer: double lock of a mutex (pid=814)
     4    [#0](/bitcoin-bitcoin/0/) pthread_mutex_lock ??:? (m.exe+0x7e3c8)
     5    [#1](/bitcoin-bitcoin/1/) __gthread_mutex_lock(pthread_mutex_t*) m.cpp:? (m.exe+0xd3d16)
     6    [#2](/bitcoin-bitcoin/2/) std::mutex::lock() ??:? (m.exe+0xd4528)
     7    [#3](/bitcoin-bitcoin/3/) std::unique_lock<std::mutex>::lock() ??:? (m.exe+0xd44b3)
     8    [#4](/bitcoin-bitcoin/4/) std::unique_lock<std::mutex>::unique_lock(std::mutex&) ??:? (m.exe+0xd4080)
     9    [#5](/bitcoin-bitcoin/5/) ThreadTwo() ??:? (m.exe+0xd38e0)
    10    [#6](/bitcoin-bitcoin/6/) void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void (*&&)()) ??:? (m.exe+0xd5ead)
    11    [#7](/bitcoin-bitcoin/7/) std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void (*&&)()) ??:? (m.exe+0xd5de0)
    12    [#8](/bitcoin-bitcoin/8/) void std::thread::_Invoker<std::tuple<void (*)()> >::_M_invoke<0ul>(std::_Index_tuple<0ul>) ??:? (m.exe+0xd5d88)
    13    [#9](/bitcoin-bitcoin/9/) std::thread::_Invoker<std::tuple<void (*)()> >::operator()() ??:? (m.exe+0xd5d28)
    14    [#10](/bitcoin-bitcoin/10/) std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> > >::_M_run() ??:? (m.exe+0xd5bff)
    15    [#11](/bitcoin-bitcoin/11/) execute_native_thread_routine /build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:80 (libstdc++.so.6+0xcfb73)
    16
    17  Location is global '<null>' at 0x000000000000 (m.exe+0x000000bb9990)
    18
    19  Mutex M13 (0x5645c381d990) created at:
    20    [#0](/bitcoin-bitcoin/0/) pthread_mutex_lock ??:? (m.exe+0x7e3c8)
    21    [#1](/bitcoin-bitcoin/1/) __gthread_mutex_lock(pthread_mutex_t*) m.cpp:? (m.exe+0xd3d16)
    22    [#2](/bitcoin-bitcoin/2/) std::mutex::lock() ??:? (m.exe+0xd4528)
    23    [#3](/bitcoin-bitcoin/3/) std::unique_lock<std::mutex>::lock() ??:? (m.exe+0xd44b3)
    24    [#4](/bitcoin-bitcoin/4/) std::unique_lock<std::mutex>::unique_lock(std::mutex&) ??:? (m.exe+0xd4080)
    25    [#5](/bitcoin-bitcoin/5/) ThreadOne() ??:? (m.exe+0xd35d0)
    26    [#6](/bitcoin-bitcoin/6/) void std::__invoke_impl<void, void (*)()>(std::__invoke_other, void (*&&)()) ??:? (m.exe+0xd5ead)
    27    [#7](/bitcoin-bitcoin/7/) std::__invoke_result<void (*)()>::type std::__invoke<void (*)()>(void (*&&)()) ??:? (m.exe+0xd5de0)
    28    [#8](/bitcoin-bitcoin/8/) void std::thread::_Invoker<std::tuple<void (*)()> >::_M_invoke<0ul>(std::_Index_tuple<0ul>) ??:? (m.exe+0xd5d88)
    29    [#9](/bitcoin-bitcoin/9/) std::thread::_Invoker<std::tuple<void (*)()> >::operator()() ??:? (m.exe+0xd5d28)
    30    [#10](/bitcoin-bitcoin/10/) std::thread::_State_impl<std::thread::_Invoker<std::tuple<void (*)()> > >::_M_run() ??:? (m.exe+0xd5bff)
    31    [#11](/bitcoin-bitcoin/11/) execute_native_thread_routine /build/gcc/src/gcc/libstdc++-v3/src/c++11/thread.cc:80 (libstdc++.so.6+0xcfb73)
    32
    33SUMMARY: ThreadSanitizer: double lock of a mutex ??:? in __interceptor_pthread_mutex_lock
    34==================
    35ThreadTwo:19
    36ThreadOne:14
    37ThreadTwo:21
    38ThreadSanitizer: reported 1 warnings
    
  19. MarcoFalke commented at 11:41 am on May 21, 2020: member

    @hebasto Even with libc++ I can not reproduce on Debian Sid:

    0$ clang++ -stdlib=libc++ -fsanitize=thread /tmp/m.cpp -o /tmp/m.exe && /tmp/m.exe
    1ThreadOne:12
    2ThreadTwo:19
    3ThreadOne:14
    4ThreadTwo:21
    

    Only in Ubuntu Focal:

      0$  clang++ -stdlib=libc++ -fsanitize=thread /tmp/m.cpp -o /tmp/m.exe && /tmp/m.exe 
      1ThreadOne:12
      2==================
      3WARNING: ThreadSanitizer: double lock of a mutex (pid=1548)
      4    [#0](/bitcoin-bitcoin/0/) pthread_mutex_lock <null> (m.exe+0x443056)
      5    [#1](/bitcoin-bitcoin/1/) std::__1::mutex::lock() <null> (libc++.so.1+0x83505)
      6    [#2](/bitcoin-bitcoin/2/) ThreadTwo() <null> (m.exe+0x4b5381)
      7    [#3](/bitcoin-bitcoin/3/) decltype(std::__1::forward<void (*)()>(fp)()) std::__1::__invoke<void (*)()>(void (*&&)()) <null> (m.exe+0x4b919d)
      8    [#4](/bitcoin-bitcoin/4/) void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>&, std::__1::__tuple_indices<>) <null> (m.exe+0x4b9088)
      9    [#5](/bitcoin-bitcoin/5/) void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()> >(void*) <null> (m.exe+0x4b8619)
     10
     11  Location is global 'm' of size 40 at 0x000000f9c928 (m.exe+0x000000f9c928)
     12
     13  Mutex M8 (0x000000f9c928) created at:
     14    [#0](/bitcoin-bitcoin/0/) pthread_mutex_lock <null> (m.exe+0x443056)
     15    [#1](/bitcoin-bitcoin/1/) std::__1::mutex::lock() <null> (libc++.so.1+0x83505)
     16    [#2](/bitcoin-bitcoin/2/) ThreadOne() <null> (m.exe+0x4b5121)
     17    [#3](/bitcoin-bitcoin/3/) decltype(std::__1::forward<void (*)()>(fp)()) std::__1::__invoke<void (*)()>(void (*&&)()) <null> (m.exe+0x4b919d)
     18    [#4](/bitcoin-bitcoin/4/) void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>&, std::__1::__tuple_indices<>) <null> (m.exe+0x4b9088)
     19    [#5](/bitcoin-bitcoin/5/) void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()> >(void*) <null> (m.exe+0x4b8619)
     20
     21SUMMARY: ThreadSanitizer: double lock of a mutex (/tmp/m.exe+0x443056) in pthread_mutex_lock
     22==================
     23==================
     24WARNING: ThreadSanitizer: data race (pid=1548)
     25  Read of size 4 at 0x0000004f5d68 by thread T2 (mutexes: write M8):
     26    [#0](/bitcoin-bitcoin/0/) std::__1::basic_ios<char, std::__1::char_traits<char> >::fill() const <null> (m.exe+0x4b6732)
     27    [#1](/bitcoin-bitcoin/1/) std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) <null> (m.exe+0x4b6010)
     28    [#2](/bitcoin-bitcoin/2/) std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<<<std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*) <null> (m.exe+0x4b59c3)
     29    [#3](/bitcoin-bitcoin/3/) ThreadTwo() <null> (m.exe+0x4b5395)
     30    [#4](/bitcoin-bitcoin/4/) decltype(std::__1::forward<void (*)()>(fp)()) std::__1::__invoke<void (*)()>(void (*&&)()) <null> (m.exe+0x4b919d)
     31    [#5](/bitcoin-bitcoin/5/) void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>&, std::__1::__tuple_indices<>) <null> (m.exe+0x4b9088)
     32    [#6](/bitcoin-bitcoin/6/) void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()> >(void*) <null> (m.exe+0x4b8619)
     33
     34  Previous write of size 4 at 0x0000004f5d68 by thread T1 (mutexes: write M8):
     35    [#0](/bitcoin-bitcoin/0/) std::__1::basic_ios<char, std::__1::char_traits<char> >::fill() const <null> (m.exe+0x4b6783)
     36    [#1](/bitcoin-bitcoin/1/) std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) <null> (m.exe+0x4b6010)
     37    [#2](/bitcoin-bitcoin/2/) std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<<<std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*) <null> (m.exe+0x4b59c3)
     38    [#3](/bitcoin-bitcoin/3/) ThreadOne() <null> (m.exe+0x4b5135)
     39    [#4](/bitcoin-bitcoin/4/) decltype(std::__1::forward<void (*)()>(fp)()) std::__1::__invoke<void (*)()>(void (*&&)()) <null> (m.exe+0x4b919d)
     40    [#5](/bitcoin-bitcoin/5/) void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>&, std::__1::__tuple_indices<>) <null> (m.exe+0x4b9088)
     41    [#6](/bitcoin-bitcoin/6/) void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()> >(void*) <null> (m.exe+0x4b8619)
     42
     43  Location is global 'std::__1::cout' of size 160 at 0x0000004f5cd0 (m.exe+0x0000004f5d68)
     44
     45  Mutex M8 (0x000000f9c928) created at:
     46    [#0](/bitcoin-bitcoin/0/) pthread_mutex_lock <null> (m.exe+0x443056)
     47    [#1](/bitcoin-bitcoin/1/) std::__1::mutex::lock() <null> (libc++.so.1+0x83505)
     48    [#2](/bitcoin-bitcoin/2/) ThreadOne() <null> (m.exe+0x4b5121)
     49    [#3](/bitcoin-bitcoin/3/) decltype(std::__1::forward<void (*)()>(fp)()) std::__1::__invoke<void (*)()>(void (*&&)()) <null> (m.exe+0x4b919d)
     50    [#4](/bitcoin-bitcoin/4/) void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>&, std::__1::__tuple_indices<>) <null> (m.exe+0x4b9088)
     51    [#5](/bitcoin-bitcoin/5/) void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()> >(void*) <null> (m.exe+0x4b8619)
     52
     53  Thread T2 (tid=1551, running) created by main thread at:
     54    [#0](/bitcoin-bitcoin/0/) pthread_create <null> (m.exe+0x425c8b)
     55    [#1](/bitcoin-bitcoin/1/) std::__1::__libcpp_thread_create(unsigned long*, void* (*)(void*), void*) <null> (m.exe+0x4b857c)
     56    [#2](/bitcoin-bitcoin/2/) std::__1::thread::thread<void (&)(), void>(void (&)()) <null> (m.exe+0x4b5d3a)
     57    [#3](/bitcoin-bitcoin/3/) main <null> (m.exe+0x4b55f8)
     58
     59  Thread T1 (tid=1550, running) created by main thread at:
     60    [#0](/bitcoin-bitcoin/0/) pthread_create <null> (m.exe+0x425c8b)
     61    [#1](/bitcoin-bitcoin/1/) std::__1::__libcpp_thread_create(unsigned long*, void* (*)(void*), void*) <null> (m.exe+0x4b857c)
     62    [#2](/bitcoin-bitcoin/2/) std::__1::thread::thread<void (&)(), void>(void (&)()) <null> (m.exe+0x4b5d3a)
     63    [#3](/bitcoin-bitcoin/3/) main <null> (m.exe+0x4b55e5)
     64
     65SUMMARY: ThreadSanitizer: data race (/tmp/m.exe+0x4b6732) in std::__1::basic_ios<char, std::__1::char_traits<char> >::fill() const
     66==================
     67==================
     68WARNING: ThreadSanitizer: data race (pid=1548)
     69  Read of size 8 at 0x0000004f5cf0 by thread T2 (mutexes: write M8):
     70    [#0](/bitcoin-bitcoin/0/) std::__1::ios_base::width() const <null> (m.exe+0x4b6909)
     71    [#1](/bitcoin-bitcoin/1/) std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) <null> (m.exe+0x4b635c)
     72    [#2](/bitcoin-bitcoin/2/) std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) <null> (m.exe+0x4b6047)
     73    [#3](/bitcoin-bitcoin/3/) std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<<<std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*) <null> (m.exe+0x4b59c3)
     74    [#4](/bitcoin-bitcoin/4/) ThreadTwo() <null> (m.exe+0x4b5395)
     75    [#5](/bitcoin-bitcoin/5/) decltype(std::__1::forward<void (*)()>(fp)()) std::__1::__invoke<void (*)()>(void (*&&)()) <null> (m.exe+0x4b919d)
     76    [#6](/bitcoin-bitcoin/6/) void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>&, std::__1::__tuple_indices<>) <null> (m.exe+0x4b9088)
     77    [#7](/bitcoin-bitcoin/7/) void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()> >(void*) <null> (m.exe+0x4b8619)
     78
     79  Previous write of size 8 at 0x0000004f5cf0 by thread T1 (mutexes: write M8):
     80    [#0](/bitcoin-bitcoin/0/) std::__1::ios_base::width(long) <null> (m.exe+0x4b6b27)
     81    [#1](/bitcoin-bitcoin/1/) std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) <null> (m.exe+0x4b654e)
     82    [#2](/bitcoin-bitcoin/2/) std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) <null> (m.exe+0x4b6047)
     83    [#3](/bitcoin-bitcoin/3/) std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<<<std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*) <null> (m.exe+0x4b59c3)
     84    [#4](/bitcoin-bitcoin/4/) ThreadOne() <null> (m.exe+0x4b5135)
     85    [#5](/bitcoin-bitcoin/5/) decltype(std::__1::forward<void (*)()>(fp)()) std::__1::__invoke<void (*)()>(void (*&&)()) <null> (m.exe+0x4b919d)
     86    [#6](/bitcoin-bitcoin/6/) void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>&, std::__1::__tuple_indices<>) <null> (m.exe+0x4b9088)
     87    [#7](/bitcoin-bitcoin/7/) void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()> >(void*) <null> (m.exe+0x4b8619)
     88
     89  Location is global 'std::__1::cout' of size 160 at 0x0000004f5cd0 (m.exe+0x0000004f5cf0)
     90
     91  Mutex M8 (0x000000f9c928) created at:
     92    [#0](/bitcoin-bitcoin/0/) pthread_mutex_lock <null> (m.exe+0x443056)
     93    [#1](/bitcoin-bitcoin/1/) std::__1::mutex::lock() <null> (libc++.so.1+0x83505)
     94    [#2](/bitcoin-bitcoin/2/) ThreadOne() <null> (m.exe+0x4b5121)
     95    [#3](/bitcoin-bitcoin/3/) decltype(std::__1::forward<void (*)()>(fp)()) std::__1::__invoke<void (*)()>(void (*&&)()) <null> (m.exe+0x4b919d)
     96    [#4](/bitcoin-bitcoin/4/) void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>&, std::__1::__tuple_indices<>) <null> (m.exe+0x4b9088)
     97    [#5](/bitcoin-bitcoin/5/) void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()> >(void*) <null> (m.exe+0x4b8619)
     98
     99  Thread T2 (tid=1551, running) created by main thread at:
    100    [#0](/bitcoin-bitcoin/0/) pthread_create <null> (m.exe+0x425c8b)
    101    [#1](/bitcoin-bitcoin/1/) std::__1::__libcpp_thread_create(unsigned long*, void* (*)(void*), void*) <null> (m.exe+0x4b857c)
    102    [#2](/bitcoin-bitcoin/2/) std::__1::thread::thread<void (&)(), void>(void (&)()) <null> (m.exe+0x4b5d3a)
    103    [#3](/bitcoin-bitcoin/3/) main <null> (m.exe+0x4b55f8)
    104
    105  Thread T1 (tid=1550, running) created by main thread at:
    106    [#0](/bitcoin-bitcoin/0/) pthread_create <null> (m.exe+0x425c8b)
    107    [#1](/bitcoin-bitcoin/1/) std::__1::__libcpp_thread_create(unsigned long*, void* (*)(void*), void*) <null> (m.exe+0x4b857c)
    108    [#2](/bitcoin-bitcoin/2/) std::__1::thread::thread<void (&)(), void>(void (&)()) <null> (m.exe+0x4b5d3a)
    109    [#3](/bitcoin-bitcoin/3/) main <null> (m.exe+0x4b55e5)
    110
    111SUMMARY: ThreadSanitizer: data race (/tmp/m.exe+0x4b6909) in std::__1::ios_base::width() const
    112==================
    113ThreadTwo:19
    114ThreadOne:14
    115ThreadTwo:21
    116ThreadSanitizer: reported 3 warnings
    
  20. hebasto commented at 11:54 am on May 21, 2020: member

    @hebasto Even with libc++ I can not reproduce on Debian Sid:

    0$ clang++ -stdlib=libc++ -fsanitize=thread /tmp/m.cpp -o /tmp/m.exe && /tmp/m.exe
    1ThreadOne:12
    2ThreadTwo:19
    3ThreadOne:14
    4ThreadTwo:21
    

    @MarcoFalke Which version of libc++ have you installed?

  21. MarcoFalke commented at 12:00 pm on May 21, 2020: member
    0# apt install libc++-dev libc++abi-dev
    1Reading package lists... Done
    2Building dependency tree       
    3Reading state information... Done
    4The following additional packages will be installed:
    5  libc++-9-dev libc++1-9 libc++abi-9-dev libc++abi1-9
    

    https://packages.debian.org/sid/libc++-dev

  22. hebasto commented at 12:02 pm on May 21, 2020: member
    0# apt install libc++-dev libc++abi-dev
    1Reading package lists... Done
    2Building dependency tree       
    3Reading state information... Done
    4The following additional packages will be installed:
    5  libc++-9-dev libc++1-9 libc++abi-9-dev libc++abi1-9
    

    https://packages.debian.org/sid/libc++-dev

    Could try https://packages.debian.org/sid/libc++-10-dev (with https://packages.debian.org/sid/libc++abi-10-dev and https://packages.debian.org/sid/clang-10) ?

  23. MarcoFalke commented at 12:05 pm on May 21, 2020: member

    Ok, so that works again.

      0$ # clang++-10 -stdlib=libc++ -fsanitize=thread /tmp/m.cpp -o /tmp/m.exe && /tmp/m.exe
      1ThreadOne:12
      2==================
      3WARNING: ThreadSanitizer: double lock of a mutex (pid=1298)
      4    [#0](/bitcoin-bitcoin/0/) pthread_mutex_lock <null> (m.exe+0x447056)
      5    [#1](/bitcoin-bitcoin/1/) std::__1::mutex::lock() <null> (libc++.so.1+0x87505)
      6    [#2](/bitcoin-bitcoin/2/) ThreadTwo() <null> (m.exe+0x4b9381)
      7    [#3](/bitcoin-bitcoin/3/) decltype(std::__1::forward<void (*)()>(fp)()) std::__1::__invoke<void (*)()>(void (*&&)()) <null> (m.exe+0x4bd19d)
      8    [#4](/bitcoin-bitcoin/4/) void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>&, std::__1::__tuple_indices<>) <null> (m.exe+0x4bd088)
      9    [#5](/bitcoin-bitcoin/5/) void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()> >(void*) <null> (m.exe+0x4bc619)
     10
     11  Location is global 'm' of size 40 at 0x000000fa0928 (m.exe+0x000000fa0928)
     12
     13  Mutex M8 (0x000000fa0928) created at:
     14    [#0](/bitcoin-bitcoin/0/) pthread_mutex_lock <null> (m.exe+0x447056)
     15    [#1](/bitcoin-bitcoin/1/) std::__1::mutex::lock() <null> (libc++.so.1+0x87505)
     16    [#2](/bitcoin-bitcoin/2/) ThreadOne() <null> (m.exe+0x4b9121)
     17    [#3](/bitcoin-bitcoin/3/) decltype(std::__1::forward<void (*)()>(fp)()) std::__1::__invoke<void (*)()>(void (*&&)()) <null> (m.exe+0x4bd19d)
     18    [#4](/bitcoin-bitcoin/4/) void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>&, std::__1::__tuple_indices<>) <null> (m.exe+0x4bd088)
     19    [#5](/bitcoin-bitcoin/5/) void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()> >(void*) <null> (m.exe+0x4bc619)
     20
     21SUMMARY: ThreadSanitizer: double lock of a mutex (/tmp/m.exe+0x447056) in pthread_mutex_lock
     22==================
     23==================
     24WARNING: ThreadSanitizer: data race (pid=1298)
     25  Read of size 4 at 0x0000004f9d68 by thread T2 (mutexes: write M8):
     26    [#0](/bitcoin-bitcoin/0/) std::__1::basic_ios<char, std::__1::char_traits<char> >::fill() const <null> (m.exe+0x4ba732)
     27    [#1](/bitcoin-bitcoin/1/) std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) <null> (m.exe+0x4ba010)
     28    [#2](/bitcoin-bitcoin/2/) std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<<<std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*) <null> (m.exe+0x4b99c3)
     29    [#3](/bitcoin-bitcoin/3/) ThreadTwo() <null> (m.exe+0x4b9395)
     30    [#4](/bitcoin-bitcoin/4/) decltype(std::__1::forward<void (*)()>(fp)()) std::__1::__invoke<void (*)()>(void (*&&)()) <null> (m.exe+0x4bd19d)
     31    [#5](/bitcoin-bitcoin/5/) void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>&, std::__1::__tuple_indices<>) <null> (m.exe+0x4bd088)
     32    [#6](/bitcoin-bitcoin/6/) void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()> >(void*) <null> (m.exe+0x4bc619)
     33
     34  Previous write of size 4 at 0x0000004f9d68 by thread T1 (mutexes: write M8):
     35    [#0](/bitcoin-bitcoin/0/) std::__1::basic_ios<char, std::__1::char_traits<char> >::fill() const <null> (m.exe+0x4ba783)
     36    [#1](/bitcoin-bitcoin/1/) std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) <null> (m.exe+0x4ba010)
     37    [#2](/bitcoin-bitcoin/2/) std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<<<std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*) <null> (m.exe+0x4b99c3)
     38    [#3](/bitcoin-bitcoin/3/) ThreadOne() <null> (m.exe+0x4b9135)
     39    [#4](/bitcoin-bitcoin/4/) decltype(std::__1::forward<void (*)()>(fp)()) std::__1::__invoke<void (*)()>(void (*&&)()) <null> (m.exe+0x4bd19d)
     40    [#5](/bitcoin-bitcoin/5/) void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>&, std::__1::__tuple_indices<>) <null> (m.exe+0x4bd088)
     41    [#6](/bitcoin-bitcoin/6/) void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()> >(void*) <null> (m.exe+0x4bc619)
     42
     43  Location is global 'std::__1::cout' of size 160 at 0x0000004f9cd0 (m.exe+0x0000004f9d68)
     44
     45  Mutex M8 (0x000000fa0928) created at:
     46    [#0](/bitcoin-bitcoin/0/) pthread_mutex_lock <null> (m.exe+0x447056)
     47    [#1](/bitcoin-bitcoin/1/) std::__1::mutex::lock() <null> (libc++.so.1+0x87505)
     48    [#2](/bitcoin-bitcoin/2/) ThreadOne() <null> (m.exe+0x4b9121)
     49    [#3](/bitcoin-bitcoin/3/) decltype(std::__1::forward<void (*)()>(fp)()) std::__1::__invoke<void (*)()>(void (*&&)()) <null> (m.exe+0x4bd19d)
     50    [#4](/bitcoin-bitcoin/4/) void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>&, std::__1::__tuple_indices<>) <null> (m.exe+0x4bd088)
     51    [#5](/bitcoin-bitcoin/5/) void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()> >(void*) <null> (m.exe+0x4bc619)
     52
     53  Thread T2 (tid=1301, running) created by main thread at:
     54    [#0](/bitcoin-bitcoin/0/) pthread_create <null> (m.exe+0x429c8b)
     55    [#1](/bitcoin-bitcoin/1/) std::__1::__libcpp_thread_create(unsigned long*, void* (*)(void*), void*) <null> (m.exe+0x4bc57c)
     56    [#2](/bitcoin-bitcoin/2/) std::__1::thread::thread<void (&)(), void>(void (&)()) <null> (m.exe+0x4b9d3a)
     57    [#3](/bitcoin-bitcoin/3/) main <null> (m.exe+0x4b95f8)
     58
     59  Thread T1 (tid=1300, running) created by main thread at:
     60    [#0](/bitcoin-bitcoin/0/) pthread_create <null> (m.exe+0x429c8b)
     61    [#1](/bitcoin-bitcoin/1/) std::__1::__libcpp_thread_create(unsigned long*, void* (*)(void*), void*) <null> (m.exe+0x4bc57c)
     62    [#2](/bitcoin-bitcoin/2/) std::__1::thread::thread<void (&)(), void>(void (&)()) <null> (m.exe+0x4b9d3a)
     63    [#3](/bitcoin-bitcoin/3/) main <null> (m.exe+0x4b95e5)
     64
     65SUMMARY: ThreadSanitizer: data race (/tmp/m.exe+0x4ba732) in std::__1::basic_ios<char, std::__1::char_traits<char> >::fill() const
     66==================
     67==================
     68WARNING: ThreadSanitizer: data race (pid=1298)
     69  Read of size 8 at 0x0000004f9cf0 by thread T2 (mutexes: write M8):
     70    [#0](/bitcoin-bitcoin/0/) std::__1::ios_base::width() const <null> (m.exe+0x4ba909)
     71    [#1](/bitcoin-bitcoin/1/) std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) <null> (m.exe+0x4ba35c)
     72    [#2](/bitcoin-bitcoin/2/) std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) <null> (m.exe+0x4ba047)
     73    [#3](/bitcoin-bitcoin/3/) std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<<<std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*) <null> (m.exe+0x4b99c3)
     74    [#4](/bitcoin-bitcoin/4/) ThreadTwo() <null> (m.exe+0x4b9395)
     75    [#5](/bitcoin-bitcoin/5/) decltype(std::__1::forward<void (*)()>(fp)()) std::__1::__invoke<void (*)()>(void (*&&)()) <null> (m.exe+0x4bd19d)
     76    [#6](/bitcoin-bitcoin/6/) void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>&, std::__1::__tuple_indices<>) <null> (m.exe+0x4bd088)
     77    [#7](/bitcoin-bitcoin/7/) void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()> >(void*) <null> (m.exe+0x4bc619)
     78
     79  Previous write of size 8 at 0x0000004f9cf0 by thread T1 (mutexes: write M8):
     80    [#0](/bitcoin-bitcoin/0/) std::__1::ios_base::width(long) <null> (m.exe+0x4bab27)
     81    [#1](/bitcoin-bitcoin/1/) std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> > std::__1::__pad_and_output<char, std::__1::char_traits<char> >(std::__1::ostreambuf_iterator<char, std::__1::char_traits<char> >, char const*, char const*, char const*, std::__1::ios_base&, char) <null> (m.exe+0x4ba54e)
     82    [#2](/bitcoin-bitcoin/2/) std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::__put_character_sequence<char, std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*, unsigned long) <null> (m.exe+0x4ba047)
     83    [#3](/bitcoin-bitcoin/3/) std::__1::basic_ostream<char, std::__1::char_traits<char> >& std::__1::operator<<<std::__1::char_traits<char> >(std::__1::basic_ostream<char, std::__1::char_traits<char> >&, char const*) <null> (m.exe+0x4b99c3)
     84    [#4](/bitcoin-bitcoin/4/) ThreadOne() <null> (m.exe+0x4b9135)
     85    [#5](/bitcoin-bitcoin/5/) decltype(std::__1::forward<void (*)()>(fp)()) std::__1::__invoke<void (*)()>(void (*&&)()) <null> (m.exe+0x4bd19d)
     86    [#6](/bitcoin-bitcoin/6/) void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>&, std::__1::__tuple_indices<>) <null> (m.exe+0x4bd088)
     87    [#7](/bitcoin-bitcoin/7/) void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()> >(void*) <null> (m.exe+0x4bc619)
     88
     89  Location is global 'std::__1::cout' of size 160 at 0x0000004f9cd0 (m.exe+0x0000004f9cf0)
     90
     91  Mutex M8 (0x000000fa0928) created at:
     92    [#0](/bitcoin-bitcoin/0/) pthread_mutex_lock <null> (m.exe+0x447056)
     93    [#1](/bitcoin-bitcoin/1/) std::__1::mutex::lock() <null> (libc++.so.1+0x87505)
     94    [#2](/bitcoin-bitcoin/2/) ThreadOne() <null> (m.exe+0x4b9121)
     95    [#3](/bitcoin-bitcoin/3/) decltype(std::__1::forward<void (*)()>(fp)()) std::__1::__invoke<void (*)()>(void (*&&)()) <null> (m.exe+0x4bd19d)
     96    [#4](/bitcoin-bitcoin/4/) void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()>&, std::__1::__tuple_indices<>) <null> (m.exe+0x4bd088)
     97    [#5](/bitcoin-bitcoin/5/) void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)()> >(void*) <null> (m.exe+0x4bc619)
     98
     99  Thread T2 (tid=1301, running) created by main thread at:
    100    [#0](/bitcoin-bitcoin/0/) pthread_create <null> (m.exe+0x429c8b)
    101    [#1](/bitcoin-bitcoin/1/) std::__1::__libcpp_thread_create(unsigned long*, void* (*)(void*), void*) <null> (m.exe+0x4bc57c)
    102    [#2](/bitcoin-bitcoin/2/) std::__1::thread::thread<void (&)(), void>(void (&)()) <null> (m.exe+0x4b9d3a)
    103    [#3](/bitcoin-bitcoin/3/) main <null> (m.exe+0x4b95f8)
    104
    105  Thread T1 (tid=1300, running) created by main thread at:
    106    [#0](/bitcoin-bitcoin/0/) pthread_create <null> (m.exe+0x429c8b)
    107    [#1](/bitcoin-bitcoin/1/) std::__1::__libcpp_thread_create(unsigned long*, void* (*)(void*), void*) <null> (m.exe+0x4bc57c)
    108    [#2](/bitcoin-bitcoin/2/) std::__1::thread::thread<void (&)(), void>(void (&)()) <null> (m.exe+0x4b9d3a)
    109    [#3](/bitcoin-bitcoin/3/) main <null> (m.exe+0x4b95e5)
    110
    111SUMMARY: ThreadSanitizer: data race (/tmp/m.exe+0x4ba909) in std::__1::ios_base::width() const
    112==================
    113ThreadTwo:19
    114ThreadOne:14
    115ThreadTwo:21
    116ThreadSanitizer: reported 3 warnings
    
  24. MarcoFalke commented at 1:28 pm on May 21, 2020: member
    Would building from depends fix the standard library issue?
  25. MarcoFalke commented at 1:30 pm on May 21, 2020: member

    cc @fanquake @dongcarl ^

    Another alternative would be to completely get rid of operating system package mangers in the sanitizer ci builds and use guix?

  26. hebasto commented at 1:30 pm on May 21, 2020: member
    #18820 is required to build from depends with libc++.
  27. hebasto commented at 3:45 pm on May 21, 2020: member

    Steps to reproduce the issue on Ubuntu 20.04:

     0$ git fetch origin pull/18820/merge:pr18820m
     1$ git switch pr18820m
     2$ make -C depends CC=clang CXX='clang++ -stdlib=libc++' NO_QT=1
     3$ ./autogen.sh
     4$ CONFIG_SITE=$PWD/depends/x86_64-pc-linux-gnu/share/config.site ./configure --disable-wallet --with-sanitizers=thread --disable-tests CC=clang CXX='clang++ -stdlib=libc++'
     5$ make
     6$ TSAN_OPTIONS="halt_on_error=1" ./src/bitcoind -noprinttoconsole
     7==================
     8WARNING: ThreadSanitizer: double lock of a mutex (pid=57183)
     9    [#0](/bitcoin-bitcoin/0/) pthread_mutex_lock <null> (bitcoind+0x82ff6)
    10    [#1](/bitcoin-bitcoin/1/) std::__1::mutex::lock() <null> (libc++.so.1+0x83505)
    11    [#2](/bitcoin-bitcoin/2/) UniqueLock<AnnotatedMixin<std::__1::mutex>, std::__1::unique_lock<std::__1::mutex> >::Enter(char const*, char const*, int) <null> (bitcoind+0x1fb591)
    12    [#3](/bitcoin-bitcoin/3/) UniqueLock<AnnotatedMixin<std::__1::mutex>, std::__1::unique_lock<std::__1::mutex> >::UniqueLock(AnnotatedMixin<std::__1::mutex>&, char const*, char const*, int, bool) <null> (bitcoind+0x18d5ad)
    13    [#4](/bitcoin-bitcoin/4/) CThreadInterrupt::sleep_for(std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000l> >) <null> (bitcoind+0x93f5be)
    14    [#5](/bitcoin-bitcoin/5/) CThreadInterrupt::sleep_for(std::__1::chrono::duration<long long, std::__1::ratio<1l, 1l> >) <null> (bitcoind+0x93f80a)
    15    [#6](/bitcoin-bitcoin/6/) CConnman::ThreadOpenAddedConnections() <null> (bitcoind+0x173ac4)
    16    [#7](/bitcoin-bitcoin/7/) decltype(*(std::__1::forward<CConnman*&>(fp0)).*fp()) std::__1::__invoke<void (CConnman::*&)(), CConnman*&, void>(void (CConnman::*&)(), CConnman*&) <null> (bitcoind+0x205b54)
    17    [#8](/bitcoin-bitcoin/8/) std::__1::__bind_return<void (CConnman::*)(), std::__1::tuple<CConnman*>, std::__1::tuple<>, __is_valid_bind_return<void (CConnman::*)(), std::__1::tuple<CConnman*>, std::__1::tuple<> >::value>::type std::__1::__apply_functor<void (CConnman::*)(), std::__1::tuple<CConnman*>, 0ul, std::__1::tuple<> >(void (CConnman::*&)(), std::__1::tuple<CConnman*>&, std::__1::__tuple_indices<0ul>, std::__1::tuple<>&&) <null> (bitcoind+0x205a10)
    18    [#9](/bitcoin-bitcoin/9/) std::__1::__bind_return<void (CConnman::*)(), std::__1::tuple<CConnman*>, std::__1::tuple<>, __is_valid_bind_return<void (CConnman::*)(), std::__1::tuple<CConnman*>, std::__1::tuple<> >::value>::type std::__1::__bind<void (CConnman::*)(), CConnman*>::operator()<>() <null> (bitcoind+0x20595e)
    19    [#10](/bitcoin-bitcoin/10/) decltype(std::__1::forward<std::__1::__bind<void (CConnman::*)(), CConnman*>&>(fp)()) std::__1::__invoke<std::__1::__bind<void (CConnman::*)(), CConnman*>&>(std::__1::__bind<void (CConnman::*)(), CConnman*>&) <null> (bitcoind+0x20587d)
    20    [#11](/bitcoin-bitcoin/11/) void std::__1::__invoke_void_return_wrapper<void>::__call<std::__1::__bind<void (CConnman::*)(), CConnman*>&>(std::__1::__bind<void (CConnman::*)(), CConnman*>&) <null> (bitcoind+0x20578d)
    21    [#12](/bitcoin-bitcoin/12/) std::__1::__function::__alloc_func<std::__1::__bind<void (CConnman::*)(), CConnman*>, std::__1::allocator<std::__1::__bind<void (CConnman::*)(), CConnman*> >, void ()>::operator()() <null> (bitcoind+0x20570d)
    22    [#13](/bitcoin-bitcoin/13/) std::__1::__function::__func<std::__1::__bind<void (CConnman::*)(), CConnman*>, std::__1::allocator<std::__1::__bind<void (CConnman::*)(), CConnman*> >, void ()>::operator()() <null> (bitcoind+0x202fdc)
    23    [#14](/bitcoin-bitcoin/14/) void TraceThread<std::__1::function<void ()> >(char const*, std::__1::function<void ()>) <null> (bitcoind+0x1210ea)
    24    [#15](/bitcoin-bitcoin/15/) decltype(std::__1::forward<void (*)(char const*, std::__1::function<void ()>)>(fp)(std::__1::forward<char const*>(fp0), std::__1::forward<std::__1::function<void ()> >(fp0))) std::__1::__invoke<void (*)(char const*, std::__1::function<void ()>), char const*, std::__1::function<void ()> >(void (*&&)(char const*, std::__1::function<void ()>), char const*&&, std::__1::function<void ()>&&) <null> (bitcoind+0x207102)
    25    [#16](/bitcoin-bitcoin/16/) void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(char const*, std::__1::function<void ()>), char const*, std::__1::function<void ()>, 2ul, 3ul>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(char const*, std::__1::function<void ()>), char const*, std::__1::function<void ()> >&, std::__1::__tuple_indices<2ul, 3ul>) <null> (bitcoind+0x206f27)
    26    [#17](/bitcoin-bitcoin/17/) void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(char const*, std::__1::function<void ()>), char const*, std::__1::function<void ()> > >(void*) <null> (bitcoind+0x2063f6)
    27
    28  Location is heap block of size 328856 at 0x7efdcf619000 allocated by main thread:
    29    [#0](/bitcoin-bitcoin/0/) operator new(unsigned long) <null> (bitcoind+0xf2b3b)
    30    [#1](/bitcoin-bitcoin/1/) AppInitMain(util::Ref const&, NodeContext&) <null> (bitcoind+0x1111c2)
    31    [#2](/bitcoin-bitcoin/2/) main <null> (bitcoind+0xf5a87)
    32
    33  Mutex M395319 (0x7efdcf669430) created at:
    34    [#0](/bitcoin-bitcoin/0/) pthread_mutex_lock <null> (bitcoind+0x82ff6)
    35    [#1](/bitcoin-bitcoin/1/) std::__1::mutex::lock() <null> (libc++.so.1+0x83505)
    36    [#2](/bitcoin-bitcoin/2/) UniqueLock<AnnotatedMixin<std::__1::mutex>, std::__1::unique_lock<std::__1::mutex> >::Enter(char const*, char const*, int) <null> (bitcoind+0x1fb591)
    37    [#3](/bitcoin-bitcoin/3/) UniqueLock<AnnotatedMixin<std::__1::mutex>, std::__1::unique_lock<std::__1::mutex> >::UniqueLock(AnnotatedMixin<std::__1::mutex>&, char const*, char const*, int, bool) <null> (bitcoind+0x18d5ad)
    38    [#4](/bitcoin-bitcoin/4/) CThreadInterrupt::sleep_for(std::__1::chrono::duration<long long, std::__1::ratio<1l, 1000l> >) <null> (bitcoind+0x93f5be)
    39    [#5](/bitcoin-bitcoin/5/) CThreadInterrupt::sleep_for(std::__1::chrono::duration<long long, std::__1::ratio<1l, 1l> >) <null> (bitcoind+0x93f80a)
    40    [#6](/bitcoin-bitcoin/6/) CConnman::ThreadDNSAddressSeed() <null> (bitcoind+0x16f669)
    41    [#7](/bitcoin-bitcoin/7/) decltype(*(std::__1::forward<CConnman*&>(fp0)).*fp()) std::__1::__invoke<void (CConnman::*&)(), CConnman*&, void>(void (CConnman::*&)(), CConnman*&) <null> (bitcoind+0x205b54)
    42    [#8](/bitcoin-bitcoin/8/) std::__1::__bind_return<void (CConnman::*)(), std::__1::tuple<CConnman*>, std::__1::tuple<>, __is_valid_bind_return<void (CConnman::*)(), std::__1::tuple<CConnman*>, std::__1::tuple<> >::value>::type std::__1::__apply_functor<void (CConnman::*)(), std::__1::tuple<CConnman*>, 0ul, std::__1::tuple<> >(void (CConnman::*&)(), std::__1::tuple<CConnman*>&, std::__1::__tuple_indices<0ul>, std::__1::tuple<>&&) <null> (bitcoind+0x205a10)
    43    [#9](/bitcoin-bitcoin/9/) std::__1::__bind_return<void (CConnman::*)(), std::__1::tuple<CConnman*>, std::__1::tuple<>, __is_valid_bind_return<void (CConnman::*)(), std::__1::tuple<CConnman*>, std::__1::tuple<> >::value>::type std::__1::__bind<void (CConnman::*)(), CConnman*>::operator()<>() <null> (bitcoind+0x20595e)
    44    [#10](/bitcoin-bitcoin/10/) decltype(std::__1::forward<std::__1::__bind<void (CConnman::*)(), CConnman*>&>(fp)()) std::__1::__invoke<std::__1::__bind<void (CConnman::*)(), CConnman*>&>(std::__1::__bind<void (CConnman::*)(), CConnman*>&) <null> (bitcoind+0x20587d)
    45    [#11](/bitcoin-bitcoin/11/) void std::__1::__invoke_void_return_wrapper<void>::__call<std::__1::__bind<void (CConnman::*)(), CConnman*>&>(std::__1::__bind<void (CConnman::*)(), CConnman*>&) <null> (bitcoind+0x20578d)
    46    [#12](/bitcoin-bitcoin/12/) std::__1::__function::__alloc_func<std::__1::__bind<void (CConnman::*)(), CConnman*>, std::__1::allocator<std::__1::__bind<void (CConnman::*)(), CConnman*> >, void ()>::operator()() <null> (bitcoind+0x20570d)
    47    [#13](/bitcoin-bitcoin/13/) std::__1::__function::__func<std::__1::__bind<void (CConnman::*)(), CConnman*>, std::__1::allocator<std::__1::__bind<void (CConnman::*)(), CConnman*> >, void ()>::operator()() <null> (bitcoind+0x202fdc)
    48    [#14](/bitcoin-bitcoin/14/) void TraceThread<std::__1::function<void ()> >(char const*, std::__1::function<void ()>) <null> (bitcoind+0x1210ea)
    49    [#15](/bitcoin-bitcoin/15/) decltype(std::__1::forward<void (*)(char const*, std::__1::function<void ()>)>(fp)(std::__1::forward<char const*>(fp0), std::__1::forward<std::__1::function<void ()> >(fp0))) std::__1::__invoke<void (*)(char const*, std::__1::function<void ()>), char const*, std::__1::function<void ()> >(void (*&&)(char const*, std::__1::function<void ()>), char const*&&, std::__1::function<void ()>&&) <null> (bitcoind+0x207102)
    50    [#16](/bitcoin-bitcoin/16/) void std::__1::__thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(char const*, std::__1::function<void ()>), char const*, std::__1::function<void ()>, 2ul, 3ul>(std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(char const*, std::__1::function<void ()>), char const*, std::__1::function<void ()> >&, std::__1::__tuple_indices<2ul, 3ul>) <null> (bitcoind+0x206f27)
    51    [#17](/bitcoin-bitcoin/17/) void* std::__1::__thread_proxy<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, void (*)(char const*, std::__1::function<void ()>), char const*, std::__1::function<void ()> > >(void*) <null> (bitcoind+0x2063f6)
    52
    53SUMMARY: ThreadSanitizer: double lock of a mutex (/home/hebasto/bitcoin/src/bitcoind+0x82ff6) in pthread_mutex_lock
    54==================
    
  28. MarcoFalke commented at 4:21 pm on May 21, 2020: member
    @hebasto How did you build depends?
  29. hebasto commented at 4:23 pm on May 21, 2020: member

    @hebasto How did you build depends?

    0$ git fetch origin pull/18820/merge:pr18820m
    1$ git switch pr18820m
    2$ make -C depends CC=clang CXX='clang++ -stdlib=libc++' NO_QT=1
    
  30. MarcoFalke commented at 5:18 pm on May 21, 2020: member
  31. hebasto commented at 5:27 pm on May 21, 2020: member

    Looks like that doesn’t pass for me: https://travis-ci.org/github/bitcoin/bitcoin/jobs/689725073#L2171

    Could your pull be built on top of the #18820 to make CXX and CC variables propagate to depends?

  32. dongcarl commented at 10:02 pm on May 22, 2020: member
    Might be worthwhile to try again now :-)
  33. MarcoFalke commented at 2:36 pm on May 31, 2020: member
    There is more than this issue. Let’s review #19041 first and then see how to proceed further.
  34. MarcoFalke closed this on May 31, 2020

  35. DrahtBot locked this on Feb 15, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-19 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me