[all-commits] [llvm/llvm-project] ee20b1: [BOLT] Fix data race in multi-threaded DWP type un...

Thrrreeee via All-commits all-commits at lists.llvm.org
Tue Jun 2 20:20:29 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: ee20b106ec70d3494890a707a32ac677c64c409d
      https://github.com/llvm/llvm-project/commit/ee20b106ec70d3494890a707a32ac677c64c409d
  Author: Thrrreeee <shijinrui at bytedance.com>
  Date:   2026-06-03 (Wed, 03 Jun 2026)

  Changed paths:
    M bolt/include/bolt/Core/BinaryContext.h
    M bolt/include/bolt/Core/DIEBuilder.h
    M bolt/lib/Core/DIEBuilder.cpp
    M bolt/lib/Rewrite/DWARFRewriter.cpp
    M bolt/lib/Rewrite/RewriteInstance.cpp
    M bolt/test/X86/dwarf5-df-types-dup-dwp-input.test
    A bolt/test/X86/dwarf5-dwp-tsan-data-race.test

  Log Message:
  -----------
  [BOLT] Fix data race in multi-threaded DWP type unit processing and DWP type unit duplication (#197359)

## Summary
This PR fixes a race condition in LLVM BOLT's
DIEBuilder::buildTypeUnits() that is triggered when DWARF5 split-DWARF
(.dwo/.dwp) inputs are processed with multi-threaded CU processing.
Concurrent invocations from different worker threads share the same DWP
type-unit state, which results in duplicated DIE extraction, assertion
failures, and intermittent crashes. The fix serializes buildTypeUnits()
for DWP inputs via a function-local static std::mutex, leaving the
non-DWO fast path unchanged.
## Problem Description
When BOLT processes DWARF debug info with --debug-thread-count=4
--cu-processing-batch-size=4 on testcase
dwarf5-df-types-dup-dwp-input.test, multiple threads concurrently call
DIEBuilder::buildTypeUnits() on shared DWP type units. Since type units
within a DWP file are shared across compilation units, multiple threads
may attempt to extract DIEs from the same type unit simultaneously,
violating the assertion.

**Note:** This is an intermittent failure — due to its dependence on
thread scheduling and interleaving, it does not reproduce on every run,
and may require multiple executions under the multi-threaded
configuration to surface, which is why it escaped earlier
single-threaded testing.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list