[llvm] Fix data race in GSYM converter (PR #225673)

via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 23 03:33:02 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-debuginfo

Author: Yuriy Chernyshov (georgthegreat)

<details>
<summary>Changes</summary>

Found this during https://github.com/yandex/perforator switch to llvm 22.

```
WARNING: ThreadSanitizer: data race (pid=15)
Read of size 8 at 0x7fff520c2f68 by main thread:
  #<!-- -->4 llvm::gsym::OutputAggregator::Report(llvm::StringRef, std::__y1::function<void (llvm::raw_ostream&)>) /-S/contrib/libs/llvm22/include/llvm/DebugInfo/GSYM/OutputAggregator.h:44:5 (race+0x8300fc)
  #<!-- -->5 llvm::gsym::DwarfTransformer::convert(unsigned int, llvm::gsym::OutputAggregator&)::$_0::operator()(llvm::DWARFUnit&) const /-S/perforator/review_15883988/race/DwarfTransformer.cpp:647:13 (race+0x832d51) (BuildId: 04d396fc8733f7b023a1c88367aeee0d88869d6c)
Previous write of size 8 at 0x7fff520c2f68 by thread T3 (mutexes: write M0):
  #<!-- -->5 llvm::gsym::OutputAggregator::Merge(llvm::gsym::OutputAggregator const&) /-S/contrib/libs/llvm22/include/llvm/DebugInfo/GSYM/OutputAggregator.h:71:7 (race+0x840df5)
  #<!-- -->6 llvm::gsym::DwarfTransformer::convert(unsigned int, llvm::gsym::OutputAggregator&)::$_2::operator()() /-S/perforator/review_15883988/race/DwarfTransformer.cpp:706:15 (race+0x840df5)
```

---
Full diff: https://github.com/llvm/llvm-project/pull/225673.diff


1 Files Affected:

- (modified) llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp (+5-1) 


``````````diff
diff --git a/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp b/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
index 4790cd1026945..b274950f83bf4 100644
--- a/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
+++ b/llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp
@@ -703,7 +703,11 @@ Error DwarfTransformer::convert(uint32_t NumThreads, OutputAggregator &Out) {
     // Now convert all DWARF to GSYM in a thread pool.
     std::mutex LogMutex;
     for (const auto &CU : DICtx.compile_units()) {
-      DWARFDie Die = getDie(*CU);
+      DWARFDie Die;
+      {
+        std::lock_guard<std::mutex> Guard(LogMutex);
+        Die = getDie(*CU);
+      }
       if (Die) {
         CUInfo CUI(DICtx, dyn_cast<DWARFCompileUnit>(CU.get()));
         pool.async([this, CUI, &LogMutex, &Out, Die]() mutable {

``````````

</details>


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


More information about the llvm-commits mailing list