[llvm] [BOLT] fix race condition in multi-threaded DWO type unit processing (PR #197359)

via llvm-commits llvm-commits at lists.llvm.org
Wed May 13 00:32:52 PDT 2026


Thrrreeee wrote:

Hi @aaupov ,
Here are my partial results from TSAN (ThreadSanitizer) detection.
```
WARNING: ThreadSanitizer: data race (pid=725727)
  Read of size 8 at 0x7b3400000d10 by thread T3:
    #0 llvm::bolt::DIEBuilder::buildTypeUnits(llvm::bolt::DebugStrOffsetsWriter*, bool) /home/jinrui/llvm-pr/bolt/lib/Core/DIEBuilder.cpp:277 (llvm-bolt+0x19f5d23)
    #1 llvm::bolt::DIEBuilder::buildDWOUnit(llvm::DWARFUnit&) /home/jinrui/llvm-pr/bolt/lib/Core/DIEBuilder.cpp:361 (llvm-bolt+0x19f6dba)
    #2 operator() /home/jinrui/llvm-pr/bolt/lib/Rewrite/DWARFRewriter.cpp:658 (llvm-bolt+0xdee601)
    #3 operator() /home/jinrui/llvm-pr/bolt/lib/Rewrite/DWARFRewriter.cpp:765 (llvm-bolt+0xdf02f6)
    #4 CallImpl<llvm::bolt::DWARFRewriter::updateDebugInfo()::<lambda()> > /home/jinrui/llvm-pr/llvm/include/llvm/ADT/FunctionExtras.h:211 (llvm-bolt+0xdf02f6)
    #5 llvm::unique_function<void ()>::operator()() /home/jinrui/llvm-pr/llvm/include/llvm/ADT/FunctionExtras.h:361 (llvm-bolt+0xdcd366)
    #6 void std::__invoke_impl<void, llvm::unique_function<void ()>>(std::__invoke_other, llvm::unique_function<void ()>&&) /usr/include/c++/8/bits/invoke.h:60 (llvm-bolt+0xdcd366)
    #7 std::__invoke_result<llvm::unique_function<void ()>>::type std::__invoke<llvm::unique_function<void ()>>(llvm::unique_function<void ()>&&) /usr/include/c++/8/bits/invoke.h:95 (llvm-bolt+0xdcd366)
    #8 decltype (__invoke((_S_declval<0ul>)())) std::thread::_Invoker<std::tuple<llvm::unique_function<void ()> > >::_M_invoke<0ul>(std::_Index_tuple<0ul>) /usr/include/c++/8/thread:244 (llvm-bolt+0xdcd366)
    #9 std::thread::_Invoker<std::tuple<llvm::unique_function<void ()> > >::operator()() /usr/include/c++/8/thread:253 (llvm-bolt+0xdcd366)
    #10 std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<llvm::unique_function<void ()> > >, void>::operator()() const /usr/include/c++/8/future:1362 (llvm-bolt+0xdcd366)
    #11 std::_Function_handler<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> (), std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<llvm::unique_function<void ()> > >, void> >::_M_invoke(std::_Any_data const&) /usr/include/c++/8/bits/std_function.h:283 (llvm-bolt+0xdcd366)
    #12 std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>::operator()() const /usr/include/c++/8/bits/std_function.h:687 (llvm-bolt+0xdcd5bc)
    #13 std::__future_base::_State_baseV2::_M_do_set(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*) /usr/include/c++/8/future:561 (llvm-bolt+0xdcd5bc)
    #14 void std::__invoke_impl<void, void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::__invoke_memfun_deref, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) /usr/include/c++/8/bits/invoke.h:73 (llvm-bolt+0xdcd554)
    #15 std::__invoke_result<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>::type std::__invoke<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) /usr/include/c++/8/bits/invoke.h:95 (llvm-bolt+0xdcd554)
    #16 std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#1}::operator()() const /usr/include/c++/8/mutex:672 (llvm-bolt+0xdcd554)
    #17 std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#2}::operator()() const /usr/include/c++/8/mutex:677 (llvm-bolt+0xdcd554)
    #18 std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#2}::_FUN() /usr/include/c++/8/mutex:677 (llvm-bolt+0xdcd554)
    #19 pthread_once <null> (libtsan.so.0+0x2d8d9)
    #20 __gthread_once /usr/include/x86_64-linux-gnu/c++/8/bits/gthr-default.h:699 (llvm-bolt+0xdcc9d2)
    #21 void std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) /usr/include/c++/8/mutex:684 (llvm-bolt+0xdcc9d2)
    #22 std::__future_base::_State_baseV2::_M_set_result(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>, bool) /usr/include/c++/8/future:401 (llvm-bolt+0xdcc9d2)
    #23 std::__future_base::_Deferred_state<std::thread::_Invoker<std::tuple<llvm::unique_function<void ()> > >, void>::_M_complete_async() /usr/include/c++/8/future:1615 (llvm-bolt+0xdcc9d2)
    #24 std::__future_base::_State_baseV2::wait() /usr/include/c++/8/future:334 (llvm-bolt+0xdcdcc0)
    #25 std::__basic_future<void>::wait() const /usr/include/c++/8/future:692 (llvm-bolt+0xdcdcc0)
    #26 llvm::ThreadPoolInterface::asyncImpl<void>(llvm::unique_function<void ()>, llvm::ThreadPoolTaskGroup*)::{lambda()#1}::operator()() const /home/jinrui/llvm-pr/llvm/include/llvm/Support/ThreadPool.h:116 (llvm-bolt+0xdcdcc0)
    #27 void llvm::detail::UniqueFunctionBase<void>::CallImpl<llvm::ThreadPoolInterface::asyncImpl<void>(llvm::unique_function<void ()>, llvm::ThreadPoolTaskGroup*)::{lambda()#1}>(void*) /home/jinrui/llvm-pr/llvm/include/llvm/ADT/FunctionExtras.h:211 (llvm-bolt+0xdcdcc0)
    #28 llvm::unique_function<void ()>::operator()() /home/jinrui/llvm-pr/llvm/include/llvm/ADT/FunctionExtras.h:361 (llvm-bolt+0x30e89fa)
    #29 llvm::StdThreadPool::processTasks(llvm::ThreadPoolTaskGroup*) /home/jinrui/llvm-pr/llvm/lib/Support/ThreadPool.cpp:119 (llvm-bolt+0x30e89fa)
    #30 operator() /home/jinrui/llvm-pr/llvm/lib/Support/ThreadPool.cpp:62 (llvm-bolt+0x30ea239)
    #31 operator()<llvm::StdThreadPool::grow(int)::<lambda()>&> /home/jinrui/llvm-pr/llvm/include/llvm/Support/thread.h:46 (llvm-bolt+0x30ea239)
    #32 __invoke_impl<void, llvm::thread::GenericThreadProxy(void*) [with CalleeTuple = std::tuple<llvm::StdThreadPool::grow(int)::<lambda()> >]::<lambda(auto:4&&, auto:5&& ...)>, llvm::StdThreadPool::grow(int)::<lambda()>&> /usr/include/c++/8/bits/invoke.h:60 (llvm-bolt+0x30ea239)
    #33 __invoke<llvm::thread::GenericThreadProxy(void*) [with CalleeTuple = std::tuple<llvm::StdThreadPool::grow(int)::<lambda()> >]::<lambda(auto:4&&, auto:5&& ...)>, llvm::StdThreadPool::grow(int)::<lambda()>&> /usr/include/c++/8/bits/invoke.h:95 (llvm-bolt+0x30ea239)
    #34 __apply_impl<llvm::thread::GenericThreadProxy(void*) [with CalleeTuple = std::tuple<llvm::StdThreadPool::grow(int)::<lambda()> >]::<lambda(auto:4&&, auto:5&& ...)>, std::tuple<llvm::StdThreadPool::grow(int)::<lambda()> >&, 0> /usr/include/c++/8/tuple:1678 (llvm-bolt+0x30ea239)
    #35 apply<llvm::thread::GenericThreadProxy(void*) [with CalleeTuple = std::tuple<llvm::StdThreadPool::grow(int)::<lambda()> >]::<lambda(auto:4&&, auto:5&& ...)>, std::tuple<llvm::StdThreadPool::grow(int)::<lambda()> >&> /usr/include/c++/8/tuple:1687 (llvm-bolt+0x30ea239)
    #36 GenericThreadProxy<std::tuple<llvm::StdThreadPool::grow(int)::<lambda()> > > /home/jinrui/llvm-pr/llvm/include/llvm/Support/thread.h:44 (llvm-bolt+0x30ea239)
    #37 ThreadProxy<std::tuple<llvm::StdThreadPool::grow(int)::<lambda()> > > /home/jinrui/llvm-pr/llvm/include/llvm/Support/thread.h:62 (llvm-bolt+0x30ea239)
    #38 <null> <null> (libtsan.so.0+0x29b3d)

  Previous write of size 8 at 0x7b3400000d10 by thread T10:
    [failed to restore the stack]

  Location is heap block of size 200 at 0x7b3400000d00 allocated by thread T10:
    #0 operator new[](unsigned long) <null> (libtsan.so.0+0x6f94a)
    #1 std::_MakeUniq<llvm::DWARFUnitIndex::Entry []>::__array std::make_unique<llvm::DWARFUnitIndex::Entry []>(unsigned long) /usr/include/c++/8/bits/unique_ptr.h:837 (llvm-bolt+0x2c08570)
    #2 llvm::DWARFUnitIndex::parseImpl(llvm::DataExtractor) /home/jinrui/llvm-pr/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp:147 (llvm-bolt+0x2c08570)
    #3 llvm::DWARFUnitIndex::parse(llvm::DataExtractor) /home/jinrui/llvm-pr/llvm/lib/DebugInfo/DWARF/DWARFUnitIndex.cpp:122 (llvm-bolt+0x2c08ceb)
    #4 getTUIndex /home/jinrui/llvm-pr/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp:344 (llvm-bolt+0x2b7e0b8)
    #5 llvm::DWARFContext::getTUIndex() /home/jinrui/llvm-pr/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp:1427 (llvm-bolt+0x2b7ea7c)
    #6 llvm::bolt::DIEBuilder::buildTypeUnits(llvm::bolt::DebugStrOffsetsWriter*, bool) /home/jinrui/llvm-pr/bolt/lib/Core/DIEBuilder.cpp:274 (llvm-bolt+0x19f5964)
    #7 llvm::bolt::DIEBuilder::buildDWOUnit(llvm::DWARFUnit&) /home/jinrui/llvm-pr/bolt/lib/Core/DIEBuilder.cpp:361 (llvm-bolt+0x19f6dba)
    #8 operator() /home/jinrui/llvm-pr/bolt/lib/Rewrite/DWARFRewriter.cpp:658 (llvm-bolt+0xdee601)
    #9 operator() /home/jinrui/llvm-pr/bolt/lib/Rewrite/DWARFRewriter.cpp:765 (llvm-bolt+0xdf02f6)
    #10 CallImpl<llvm::bolt::DWARFRewriter::updateDebugInfo()::<lambda()> > /home/jinrui/llvm-pr/llvm/include/llvm/ADT/FunctionExtras.h:211 (llvm-bolt+0xdf02f6)
    #11 llvm::unique_function<void ()>::operator()() /home/jinrui/llvm-pr/llvm/include/llvm/ADT/FunctionExtras.h:361 (llvm-bolt+0xdcd366)
    #12 void std::__invoke_impl<void, llvm::unique_function<void ()>>(std::__invoke_other, llvm::unique_function<void ()>&&) /usr/include/c++/8/bits/invoke.h:60 (llvm-bolt+0xdcd366)
    #13 std::__invoke_result<llvm::unique_function<void ()>>::type std::__invoke<llvm::unique_function<void ()>>(llvm::unique_function<void ()>&&) /usr/include/c++/8/bits/invoke.h:95 (llvm-bolt+0xdcd366)
    #14 decltype (__invoke((_S_declval<0ul>)())) std::thread::_Invoker<std::tuple<llvm::unique_function<void ()> > >::_M_invoke<0ul>(std::_Index_tuple<0ul>) /usr/include/c++/8/thread:244 (llvm-bolt+0xdcd366)
    #15 std::thread::_Invoker<std::tuple<llvm::unique_function<void ()> > >::operator()() /usr/include/c++/8/thread:253 (llvm-bolt+0xdcd366)
    #16 std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<llvm::unique_function<void ()> > >, void>::operator()() const /usr/include/c++/8/future:1362 (llvm-bolt+0xdcd366)
    #17 std::_Function_handler<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> (), std::__future_base::_Task_setter<std::unique_ptr<std::__future_base::_Result<void>, std::__future_base::_Result_base::_Deleter>, std::thread::_Invoker<std::tuple<llvm::unique_function<void ()> > >, void> >::_M_invoke(std::_Any_data const&) /usr/include/c++/8/bits/std_function.h:283 (llvm-bolt+0xdcd366)
    #18 std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>::operator()() const /usr/include/c++/8/bits/std_function.h:687 (llvm-bolt+0xdcd5bc)
    #19 std::__future_base::_State_baseV2::_M_do_set(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*) /usr/include/c++/8/future:561 (llvm-bolt+0xdcd5bc)
    #20 void std::__invoke_impl<void, void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::__invoke_memfun_deref, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) /usr/include/c++/8/bits/invoke.h:73 (llvm-bolt+0xdcd554)
    #21 std::__invoke_result<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>::type std::__invoke<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) /usr/include/c++/8/bits/invoke.h:95 (llvm-bolt+0xdcd554)
    #22 std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#1}::operator()() const /usr/include/c++/8/mutex:672 (llvm-bolt+0xdcd554)
    #23 std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#2}::operator()() const /usr/include/c++/8/mutex:677 (llvm-bolt+0xdcd554)
    #24 std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&)::{lambda()#2}::_FUN() /usr/include/c++/8/mutex:677 (llvm-bolt+0xdcd554)
    #25 pthread_once <null> (libtsan.so.0+0x2d8d9)
    #26 __gthread_once /usr/include/x86_64-linux-gnu/c++/8/bits/gthr-default.h:699 (llvm-bolt+0xdcc9d2)
    #27 void std::call_once<void (std::__future_base::_State_baseV2::*)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*>(std::once_flag&, void (std::__future_base::_State_baseV2::*&&)(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*, bool*), std::__future_base::_State_baseV2*&&, std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>*&&, bool*&&) /usr/include/c++/8/mutex:684 (llvm-bolt+0xdcc9d2)
    #28 std::__future_base::_State_baseV2::_M_set_result(std::function<std::unique_ptr<std::__future_base::_Result_base, std::__future_base::_Result_base::_Deleter> ()>, bool) /usr/include/c++/8/future:401 (llvm-bolt+0xdcc9d2)
    #29 std::__future_base::_Deferred_state<std::thread::_Invoker<std::tuple<llvm::unique_function<void ()> > >, void>::_M_complete_async() /usr/include/c++/8/future:1615 (llvm-bolt+0xdcc9d2)
    #30 std::__future_base::_State_baseV2::wait() /usr/include/c++/8/future:334 (llvm-bolt+0xdcdcc0)
    #31 std::__basic_future<void>::wait() const /usr/include/c++/8/future:692 (llvm-bolt+0xdcdcc0)
    #32 llvm::ThreadPoolInterface::asyncImpl<void>(llvm::unique_function<void ()>, llvm::ThreadPoolTaskGroup*)::{lambda()#1}::operator()() const /home/jinrui/llvm-pr/llvm/include/llvm/Support/ThreadPool.h:116 (llvm-bolt+0xdcdcc0)
    #33 void llvm::detail::UniqueFunctionBase<void>::CallImpl<llvm::ThreadPoolInterface::asyncImpl<void>(llvm::unique_function<void ()>, llvm::ThreadPoolTaskGroup*)::{lambda()#1}>(void*) /home/jinrui/llvm-pr/llvm/include/llvm/ADT/FunctionExtras.h:211 (llvm-bolt+0xdcdcc0)
    #34 llvm::unique_function<void ()>::operator()() /home/jinrui/llvm-pr/llvm/include/llvm/ADT/FunctionExtras.h:361 (llvm-bolt+0x30e89fa)
    #35 llvm::StdThreadPool::processTasks(llvm::ThreadPoolTaskGroup*) /home/jinrui/llvm-pr/llvm/lib/Support/ThreadPool.cpp:119 (llvm-bolt+0x30e89fa)
    #36 operator() /home/jinrui/llvm-pr/llvm/lib/Support/ThreadPool.cpp:62 (llvm-bolt+0x30ea239)
    #37 operator()<llvm::StdThreadPool::grow(int)::<lambda()>&> /home/jinrui/llvm-pr/llvm/include/llvm/Support/thread.h:46 (llvm-bolt+0x30ea239)
    #38 __invoke_impl<void, llvm::thread::GenericThreadProxy(void*) [with CalleeTuple = std::tuple<llvm::StdThreadPool::grow(int)::<lambda()> >]::<lambda(auto:4&&, auto:5&& ...)>, llvm::StdThreadPool::grow(int)::<lambda()>&> /usr/include/c++/8/bits/invoke.h:60 (llvm-bolt+0x30ea239)
    #39 __invoke<llvm::thread::GenericThreadProxy(void*) [with CalleeTuple = std::tuple<llvm::StdThreadPool::grow(int)::<lambda()> >]::<lambda(auto:4&&, auto:5&& ...)>, llvm::StdThreadPool::grow(int)::<lambda()>&> /usr/include/c++/8/bits/invoke.h:95 (llvm-bolt+0x30ea239)
    #40 __apply_impl<llvm::thread::GenericThreadProxy(void*) [with CalleeTuple = std::tuple<llvm::StdThreadPool::grow(int)::<lambda()> >]::<lambda(auto:4&&, auto:5&& ...)>, std::tuple<llvm::StdThreadPool::grow(int)::<lambda()> >&, 0> /usr/include/c++/8/tuple:1678 (llvm-bolt+0x30ea239)
    #41 apply<llvm::thread::GenericThreadProxy(void*) [with CalleeTuple = std::tuple<llvm::StdThreadPool::grow(int)::<lambda()> >]::<lambda(auto:4&&, auto:5&& ...)>, std::tuple<llvm::StdThreadPool::grow(int)::<lambda()> >&> /usr/include/c++/8/tuple:1687 (llvm-bolt+0x30ea239)
    #42 GenericThreadProxy<std::tuple<llvm::StdThreadPool::grow(int)::<lambda()> > > /home/jinrui/llvm-pr/llvm/include/llvm/Support/thread.h:44 (llvm-bolt+0x30ea239)
    #43 ThreadProxy<std::tuple<llvm::StdThreadPool::grow(int)::<lambda()> > > /home/jinrui/llvm-pr/llvm/include/llvm/Support/thread.h:62 (llvm-bolt+0x30ea239)
    #44 <null> <null> (libtsan.so.0+0x29b3d)

  Thread T3 'llvm-worker-2' (tid=725731, running) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x2be1b)
    #1 llvm::llvm_execute_on_thread_impl(void* (*)(void*), void*, std::optional<unsigned int>) /home/jinrui/llvm-pr/llvm/lib/Support/Unix/Threading.inc:95 (llvm-bolt+0xc4a2e3)
    #2 thread<llvm::StdThreadPool::grow(int)::<lambda()>&> /home/jinrui/llvm-pr/llvm/include/llvm/Support/thread.h:138 (llvm-bolt+0x30e390b)
    #3 emplace_back<llvm::StdThreadPool::grow(int)::<lambda()> > /home/jinrui/llvm-pr/llvm/include/llvm/Support/thread.h:85 (llvm-bolt+0x30e41fe)
    #4 llvm::StdThreadPool::grow(int) /home/jinrui/llvm-pr/llvm/lib/Support/ThreadPool.cpp:63 (llvm-bolt+0x30e41fe)
    #5 llvm::StdThreadPool::asyncEnqueue(llvm::unique_function<void ()>, llvm::ThreadPoolTaskGroup*) /home/jinrui/llvm-pr/llvm/include/llvm/Support/ThreadPool.h:176 (llvm-bolt+0x30e4d21)
    #6 async<llvm::bolt::ParallelUtilities::runOnEachFunctionWithUniqueAllocId(llvm::bolt::BinaryContext&, llvm::bolt::ParallelUtilities::SchedulingPolicy, llvm::bolt::ParallelUtilities::WorkFuncWithAllocTy, llvm::bolt::ParallelUtilities::PredicateTy, std::__cxx11::string, bool, unsigned int)::<lambda(std::map<long unsigned int, llvm::bolt::BinaryFunction>::iterator, std::map<long unsigned int, llvm::bolt::BinaryFunction>::iterator, llvm::bolt::MCPlusBuilder::AllocatorIdTy)>&, std::_Rb_tree_iterator<std::pair<long unsigned int const, llvm::bolt::BinaryFunction> >&, std::_Rb_tree_iterator<std::pair<long unsigned int const, llvm::bolt::BinaryFunction> >, unsigned int&> /home/jinrui/llvm-pr/llvm/include/llvm/Support/ThreadPool.h:116 (llvm-bolt+0x1a2d71e)
    #7 llvm::bolt::ParallelUtilities::runOnEachFunctionWithUniqueAllocId(llvm::bolt::BinaryContext&, llvm::bolt::ParallelUtilities::SchedulingPolicy, std::function<void (llvm::bolt::BinaryFunction&, unsigned short)>, std::function<bool (llvm::bolt::BinaryFunction const&)>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, unsigned int) /home/jinrui/llvm-pr/bolt/lib/Core/ParallelUtilities.cpp:230 (llvm-bolt+0x1a2d71e)
    #8 llvm::bolt::RewriteInstance::buildFunctionsCFG() /home/jinrui/llvm-pr/bolt/lib/Rewrite/RewriteInstance.cpp:3833 (llvm-bolt+0xd341f2)
    #9 llvm::bolt::RewriteInstance::run() /home/jinrui/llvm-pr/bolt/lib/Rewrite/RewriteInstance.cpp:803 (llvm-bolt+0xdbb513)
    #10 main /home/jinrui/llvm-pr/bolt/tools/driver/llvm-bolt.cpp:267 (llvm-bolt+0xc5cd0)

  Thread T10 'llvm-worker-9' (tid=725738, running) created by main thread at:
    #0 pthread_create <null> (libtsan.so.0+0x2be1b)
    #1 llvm::llvm_execute_on_thread_impl(void* (*)(void*), void*, std::optional<unsigned int>) /home/jinrui/llvm-pr/llvm/lib/Support/Unix/Threading.inc:95 (llvm-bolt+0xc4a2e3)
    #2 thread<llvm::StdThreadPool::grow(int)::<lambda()>&> /home/jinrui/llvm-pr/llvm/include/llvm/Support/thread.h:138 (llvm-bolt+0x30e390b)
    #3 thread<llvm::StdThreadPool::grow(int)::<lambda()> > /home/jinrui/llvm-pr/llvm/include/llvm/Support/thread.h:85 (llvm-bolt+0x30e4123)
    #4 construct<llvm::thread, llvm::StdThreadPool::grow(int)::<lambda()> > /usr/include/c++/8/ext/new_allocator.h:136 (llvm-bolt+0x30e4123)
    #5 construct<llvm::thread, llvm::StdThreadPool::grow(int)::<lambda()> > /usr/include/c++/8/bits/alloc_traits.h:475 (llvm-bolt+0x30e4123)
    #6 emplace_back<llvm::StdThreadPool::grow(int)::<lambda()> > /usr/include/c++/8/bits/vector.tcc:103 (llvm-bolt+0x30e4123)
    #7 llvm::StdThreadPool::grow(int) /home/jinrui/llvm-pr/llvm/lib/Support/ThreadPool.cpp:63 (llvm-bolt+0x30e4123)
    #8 llvm::StdThreadPool::asyncEnqueue(llvm::unique_function<void ()>, llvm::ThreadPoolTaskGroup*) /home/jinrui/llvm-pr/llvm/include/llvm/Support/ThreadPool.h:176 (llvm-bolt+0x30e4d21)
    #9 async<llvm::bolt::ParallelUtilities::runOnEachFunctionWithUniqueAllocId(llvm::bolt::BinaryContext&, llvm::bolt::ParallelUtilities::SchedulingPolicy, llvm::bolt::ParallelUtilities::WorkFuncWithAllocTy, llvm::bolt::ParallelUtilities::PredicateTy, std::__cxx11::string, bool, unsigned int)::<lambda(std::map<long unsigned int, llvm::bolt::BinaryFunction>::iterator, std::map<long unsigned int, llvm::bolt::BinaryFunction>::iterator, llvm::bolt::MCPlusBuilder::AllocatorIdTy)>&, std::_Rb_tree_iterator<std::pair<long unsigned int const, llvm::bolt::BinaryFunction> >&, std::_Rb_tree_iterator<std::pair<long unsigned int const, llvm::bolt::BinaryFunction> >, unsigned int&> /home/jinrui/llvm-pr/llvm/include/llvm/Support/ThreadPool.h:116 (llvm-bolt+0x1a2d71e)
    #10 llvm::bolt::ParallelUtilities::runOnEachFunctionWithUniqueAllocId(llvm::bolt::BinaryContext&, llvm::bolt::ParallelUtilities::SchedulingPolicy, std::function<void (llvm::bolt::BinaryFunction&, unsigned short)>, std::function<bool (llvm::bolt::BinaryFunction const&)>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, unsigned int) /home/jinrui/llvm-pr/bolt/lib/Core/ParallelUtilities.cpp:230 (llvm-bolt+0x1a2d71e)
    #11 llvm::bolt::RewriteInstance::buildFunctionsCFG() /home/jinrui/llvm-pr/bolt/lib/Rewrite/RewriteInstance.cpp:3833 (llvm-bolt+0xd341f2)
    #12 llvm::bolt::RewriteInstance::run() /home/jinrui/llvm-pr/bolt/lib/Rewrite/RewriteInstance.cpp:803 (llvm-bolt+0xdbb513)
    #13 main /home/jinrui/llvm-pr/bolt/tools/driver/llvm-bolt.cpp:267 (llvm-bolt+0xc5cd0)

SUMMARY: ThreadSanitizer: data race /home/jinrui/llvm-pr/bolt/lib/Core/DIEBuilder.cpp:277 in llvm::bolt::DIEBuilder::buildTypeUnits(llvm::bolt::DebugStrOffsetsWriter*, bool)
```

https://github.com/llvm/llvm-project/pull/197359


More information about the llvm-commits mailing list