Skip to content

[CLANG][DWARF] Handle DIE offset collision in DW_IDX_parent #95039

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 12, 2024

Conversation

ayermolo
Copy link
Contributor

This fixes #93886. The UnitID is not
unique between CUs and TUs. This led to DW_IDX_parent to point ot an entry for a
DIE in a CU if it had the same relative offset as a TU die.

Added a IsTU to the hash for parent chain.

This fixes llvm#93886. The UnitID is not
unique between CUs and TUs. This led to DW_IDX_parent to point ot an entry for a
DIE in CU if it had the same relative offset as TU die.

Added a IsTU to the hash for parent chain.
@llvmbot
Copy link
Member

llvmbot commented Jun 10, 2024

@llvm/pr-subscribers-debuginfo

Author: Alexander Yermolovich (ayermolo)

Changes

This fixes #93886. The UnitID is not
unique between CUs and TUs. This led to DW_IDX_parent to point ot an entry for a
DIE in a CU if it had the same relative offset as a TU die.

Added a IsTU to the hash for parent chain.


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

5 Files Affected:

  • (modified) llvm/include/llvm/CodeGen/AccelTable.h (+34-15)
  • (modified) llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (+2-1)
  • (modified) llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp (+6-3)
  • (modified) llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp (+4-3)
  • (added) llvm/test/DebugInfo/X86/debug-names-types-die-offset-collision.ll (+69)
diff --git a/llvm/include/llvm/CodeGen/AccelTable.h b/llvm/include/llvm/CodeGen/AccelTable.h
index cff8fcbaf2cd7..622fcf019aad6 100644
--- a/llvm/include/llvm/CodeGen/AccelTable.h
+++ b/llvm/include/llvm/CodeGen/AccelTable.h
@@ -257,17 +257,37 @@ class AppleAccelTableData : public AccelTableData {
 
 /// Helper class to identify an entry in DWARF5AccelTable based on their DIE
 /// offset and UnitID.
-struct OffsetAndUnitID : std::pair<uint64_t, uint32_t> {
-  using Base = std::pair<uint64_t, uint32_t>;
-  OffsetAndUnitID(Base B) : Base(B) {}
-
-  OffsetAndUnitID(uint64_t Offset, uint32_t UnitID) : Base(Offset, UnitID) {}
-  uint64_t offset() const { return first; };
-  uint32_t unitID() const { return second; };
+struct OffsetAndUnitID {
+  uint64_t Offset = 0;
+  uint32_t UnitID = 0;
+  bool IsTU = false;
+  OffsetAndUnitID() = default;
+  OffsetAndUnitID(uint64_t Offset, uint32_t UnitID, bool IsTU)
+      : Offset(Offset), UnitID(UnitID), IsTU(IsTU) {}
+  uint64_t offset() const { return Offset; };
+  uint32_t unitID() const { return UnitID; };
+  bool isTU() const { return IsTU; }
 };
 
-template <>
-struct DenseMapInfo<OffsetAndUnitID> : DenseMapInfo<OffsetAndUnitID::Base> {};
+template <> struct DenseMapInfo<OffsetAndUnitID> {
+  static inline OffsetAndUnitID getEmptyKey() {
+    OffsetAndUnitID Entry;
+    Entry.Offset = uint64_t(-1);
+    return Entry;
+  }
+  static inline OffsetAndUnitID getTombstoneKey() {
+    OffsetAndUnitID Entry;
+    Entry.Offset = uint64_t(-2);
+    return Entry;
+  }
+  static unsigned getHashValue(const OffsetAndUnitID &Val) {
+    return (unsigned)llvm::hash_combine(Val.offset(), Val.unitID(), Val.IsTU);
+  }
+  static bool isEqual(const OffsetAndUnitID &LHS, const OffsetAndUnitID &RHS) {
+    return LHS.offset() == RHS.offset() && LHS.unitID() == RHS.unitID() &&
+           LHS.IsTU == RHS.isTU();
+  }
+};
 
 /// The Data class implementation for DWARF v5 accelerator table. Unlike the
 /// Apple Data classes, this class is just a DIE wrapper, and does not know to
@@ -277,12 +297,11 @@ class DWARF5AccelTableData : public AccelTableData {
 public:
   static uint32_t hash(StringRef Name) { return caseFoldingDjbHash(Name); }
 
-  DWARF5AccelTableData(const DIE &Die, const uint32_t UnitID,
-                       const bool IsTU = false);
+  DWARF5AccelTableData(const DIE &Die, const uint32_t UnitID, const bool IsTU);
   DWARF5AccelTableData(const uint64_t DieOffset,
                        const std::optional<uint64_t> DefiningParentOffset,
                        const unsigned DieTag, const unsigned UnitID,
-                       const bool IsTU = false)
+                       const bool IsTU)
       : OffsetVal(DieOffset), ParentOffset(DefiningParentOffset),
         DieTag(DieTag), AbbrevNumber(0), IsTU(IsTU), UnitID(UnitID) {}
 
@@ -296,7 +315,7 @@ class DWARF5AccelTableData : public AccelTableData {
   }
 
   OffsetAndUnitID getDieOffsetAndUnitID() const {
-    return {getDieOffset(), UnitID};
+    return {getDieOffset(), getUnitID(), isTU()};
   }
 
   unsigned getDieTag() const { return DieTag; }
@@ -322,7 +341,7 @@ class DWARF5AccelTableData : public AccelTableData {
     assert(isNormalized() && "Accessing DIE Offset before normalizing.");
     if (!ParentOffset)
       return std::nullopt;
-    return OffsetAndUnitID(*ParentOffset, getUnitID());
+    return OffsetAndUnitID(*ParentOffset, getUnitID(), isTU());
   }
 
   /// Sets AbbrevIndex for an Entry.
@@ -416,7 +435,7 @@ class DWARF5AccelTable : public AccelTable<DWARF5AccelTableData> {
       for (auto *Data : Entry.second.getValues<DWARF5AccelTableData *>()) {
         addName(Entry.second.Name, Data->getDieOffset(),
                 Data->getParentDieOffset(), Data->getDieTag(),
-                Data->getUnitID(), true);
+                Data->getUnitID(), Data->isTU());
       }
     }
   }
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index b9c02aed848cc..7de9432325d8a 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -3592,7 +3592,8 @@ void DwarfDebug::addAccelNameImpl(
                "Kind is TU but CU is being processed.");
     // The type unit can be discarded, so need to add references to final
     // acceleration table once we know it's complete and we emit it.
-    Current.addName(Ref, Die, Unit.getUniqueID());
+    Current.addName(Ref, Die, Unit.getUniqueID(),
+                    Unit.getUnitDie().getTag() == dwarf::DW_TAG_type_unit);
     break;
   }
   case AccelTableKind::Default:
diff --git a/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp b/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
index 2544d97eaafd0..f6aaf88bb5fb7 100644
--- a/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
@@ -2247,17 +2247,20 @@ void DWARFLinker::emitAcceleratorEntriesForUnit(CompileUnit &Unit) {
         DebugNames.addName(
             Namespace.Name, Namespace.Die->getOffset(),
             DWARF5AccelTableData::getDefiningParentDieOffset(*Namespace.Die),
-            Namespace.Die->getTag(), Unit.getUniqueID());
+            Namespace.Die->getTag(), Unit.getUniqueID(),
+            Unit.getOutputUnitDIE()->getTag() == dwarf::DW_TAG_type_unit);
       for (const auto &Pubname : Unit.getPubnames())
         DebugNames.addName(
             Pubname.Name, Pubname.Die->getOffset(),
             DWARF5AccelTableData::getDefiningParentDieOffset(*Pubname.Die),
-            Pubname.Die->getTag(), Unit.getUniqueID());
+            Pubname.Die->getTag(), Unit.getUniqueID(),
+            Unit.getOutputUnitDIE()->getTag() == dwarf::DW_TAG_type_unit);
       for (const auto &Pubtype : Unit.getPubtypes())
         DebugNames.addName(
             Pubtype.Name, Pubtype.Die->getOffset(),
             DWARF5AccelTableData::getDefiningParentDieOffset(*Pubtype.Die),
-            Pubtype.Die->getTag(), Unit.getUniqueID());
+            Pubtype.Die->getTag(), Unit.getUniqueID(),
+            Unit.getOutputUnitDIE()->getTag() == dwarf::DW_TAG_type_unit);
     } break;
     }
   }
diff --git a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp
index e68bf0c227a0a..a068ec1a3056d 100644
--- a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp
+++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp
@@ -1356,9 +1356,10 @@ void DWARFLinkerImpl::emitDWARFv5DebugNamesSection(const Triple &TargetTriple) {
       case DwarfUnit::AccelType::Name:
       case DwarfUnit::AccelType::Namespace:
       case DwarfUnit::AccelType::Type: {
-        DebugNames->addName(*DebugStrStrings.getExistingEntry(Info.String),
-                            Info.OutOffset, std::nullopt /*ParentDIEOffset*/,
-                            Info.Tag, CU->getUniqueID());
+        DebugNames->addName(
+            *DebugStrStrings.getExistingEntry(Info.String), Info.OutOffset,
+            std::nullopt /*ParentDIEOffset*/, Info.Tag, CU->getUniqueID(),
+            CU->getOutUnitDIE()->getTag() == dwarf::DW_TAG_type_unit);
       } break;
 
       default:
diff --git a/llvm/test/DebugInfo/X86/debug-names-types-die-offset-collision.ll b/llvm/test/DebugInfo/X86/debug-names-types-die-offset-collision.ll
new file mode 100644
index 0000000000000..104a166ffd3ad
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/debug-names-types-die-offset-collision.ll
@@ -0,0 +1,69 @@
+; UNSUPPORTED: system-windows
+
+;; This test checks that DW_IDX_parent is generated correctly when there is DIE relative offset collision between CU and TU.
+
+; RUN: llc -mtriple=x86_64 -generate-type-units -dwarf-version=5 -filetype=obj %s -o %t
+; RUN: llvm-dwarfdump -debug-info -debug-names %t | FileCheck %s
+
+; CHECK: .debug_info contents:
+; CHECK:        0x00000023:   DW_TAG_namespace
+; CHECK-NEXT:                   DW_AT_name  ("B")
+; CHECK:        0x00000023:   DW_TAG_subprogram
+; CHECK-NEXT:                   DW_AT_low_pc
+; CHECK-NEXT:                   DW_AT_high_pc
+; CHECK-NEXT:                   DW_AT_frame_base
+; CHECK-NEXT:                   DW_AT_linkage_name  ("_Z9get_statev")
+; CHECK-NEXT:                   DW_AT_name  ("get_state")
+
+; CHECK: .debug_names contents:
+; CHECK:  String: {{.*}} "B"
+; CHECK:        Entry @ [[ENTRY:0x[0-9a-f]*]]
+; CHECK:  String: {{.*}} "State"
+; CHECK:        Entry @ 0xd3 {
+; CHECK:          Abbrev: 0x4
+; CHECK:          Tag: DW_TAG_structure_type
+; CHECK:          DW_IDX_type_unit: 0x00
+; CHECK:          DW_IDX_die_offset: 0x00000025
+; CHECK:          DW_IDX_parent: Entry @ [[ENTRY:0x[0-9a-f]*]]
+; CHECK:        }
+
+
+;; namespace B { struct State { class InnerState{}; }; }
+;; B::State::InnerState get_state() { return B::State::InnerState(); }
+;; clang++ main.cpp -g2 -O0 -fdebug-types-section -gpubnames
+
+; ModuleID = 'main.cpp'
+source_filename = "main.cpp"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: mustprogress noinline nounwind optnone uwtable
+define dso_local void @_Z9get_statev() #0 !dbg !10 {
+entry:
+  ret void, !dbg !17
+}
+
+attributes #0 = { mustprogress noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8}
+!llvm.ident = !{!9}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 19.0.0git", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false)
+!1 = !DIFile(filename: "main.cpp", directory: "/folder", checksumkind: CSK_MD5, checksum: "a84fe2e4ecb77633f6c33f3b6833b9e7")
+!2 = !{i32 7, !"Dwarf Version", i32 5}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = !{i32 1, !"wchar_size", i32 4}
+!5 = !{i32 8, !"PIC Level", i32 2}
+!6 = !{i32 7, !"PIE Level", i32 2}
+!7 = !{i32 7, !"uwtable", i32 2}
+!8 = !{i32 7, !"frame-pointer", i32 2}
+!9 = !{!"clang version 19.0.0git"}
+!10 = distinct !DISubprogram(name: "get_state", linkageName: "_Z9get_statev", scope: !1, file: !1, line: 2, type: !11, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0)
+!11 = !DISubroutineType(types: !12)
+!12 = !{!13}
+!13 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "InnerState", scope: !14, file: !1, line: 1, size: 8, flags: DIFlagTypePassByValue, elements: !16, identifier: "_ZTSN1B5State10InnerStateE")
+!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "State", scope: !15, file: !1, line: 1, size: 8, flags: DIFlagTypePassByValue, elements: !16, identifier: "_ZTSN1B5StateE")
+!15 = !DINamespace(name: "B", scope: null)
+!16 = !{}
+!17 = !DILocation(line: 2, column: 36, scope: !10)

@ayermolo ayermolo changed the title y [CLANG][DWARF] Handle DIE offset collision in DW_IDX_parent Jun 10, 2024
Copy link
Contributor

@felipepiovezan felipepiovezan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this! LGTM but left a suggestion to use a tuple if you also believe it would simplify the code

@@ -257,17 +257,37 @@ class AppleAccelTableData : public AccelTableData {

/// Helper class to identify an entry in DWARF5AccelTable based on their DIE
/// offset and UnitID.
struct OffsetAndUnitID : std::pair<uint64_t, uint32_t> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make it sense to just use tuple here to avoid having to define the dense map boilerplate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really have a strong opinion. Poking around I don't really see tuple being used with DenseMap. More standard approach seems this boilerplate code.
@dwblaikie to break a tie? :)

@ayermolo ayermolo merged commit f59d9d5 into llvm:main Jun 12, 2024
9 checks passed
@ayermolo
Copy link
Contributor Author

Merged, if there is a strong opinion about tuple I can put up follow up PR.

@dwblaikie
Copy link
Collaborator

Out on vacation until tomorrow, but did you try making the die numbering unique across type and compile units? I would've thought that might be simpler, but maybe had too many knock-on effects/other things that'd need fixing/changing.

@ayermolo
Copy link
Contributor Author

Out on vacation until tomorrow, but did you try making the die numbering unique across type and compile units? I would've thought that might be simpler, but maybe had too many knock-on effects/other things that'd need fixing/changing.

I thought this would be a less intrusive change.
Unifying IDs would have brought up how to handle TUs that get discarded. We need UniqueID set for when we create entries, at which point we don't know if this CU will be discarded or not.
There is also a question of how/where CU unique ID is used. For example it is passed into emitDwarfFile0Directive. Under the hood it access MCDwarfLineTablesCUMap. It's a map so probably fine to have non sequential IDs. On flip side code in emitDWARF5AccelTable relies on it being sequential (although fix would be super minor) So I think this is a less risky way of fixing the issue.

@fmayer
Copy link
Contributor

fmayer commented Jun 12, 2024

I think this broke the ASan bot:

=================================================================
==120988==ERROR: AddressSanitizer: heap-use-after-free on address 0x52100002d11c at pc 0x563e760d1c6d bp 0x7f0eef1c59d0 sp 0x7f0eef1c59c8
READ of size 2 at 0x52100002d11c thread T20
    #0 0x563e760d1c6c in getTag /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/CodeGen/DIE.h:855:38
    #1 0x563e760d1c6c in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp:1362:34
    #2 0x563e760d1c6c in void llvm::function_ref<void (llvm::dwarf_linker::parallel::DwarfUnit::AccelInfo&)>::callback_fn<llvm::dwarf_linker::parallel::DWARFLinkerImpl::emitDWARFv5DebugNamesSection(llvm::Triple const&)::$_0::operator()(llvm::dwarf_linker::parallel::DwarfUnit*) const::'lambda'(llvm::dwarf_linker::parallel::DwarfUnit::AccelInfo const&)>(long, llvm::dwarf_linker::parallel::DwarfUnit::AccelInfo&) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
    #3 0x563e76114898 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
    #4 0x563e76114898 in forEach /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/DWARFLinker/Parallel/ArrayList.h:67:9
    #5 0x563e76114898 in llvm::dwarf_linker::parallel::CompileUnit::forEachAcceleratorRecord(llvm::function_ref<void (llvm::dwarf_linker::parallel::DwarfUnit::AccelInfo&)>) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.h:576:24
    #6 0x563e760d12e7 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp:1350:9
    #7 0x563e760d12e7 in void llvm::function_ref<void (llvm::dwarf_linker::parallel::DwarfUnit*)>::callback_fn<llvm::dwarf_linker::parallel::DWARFLinkerImpl::emitDWARFv5DebugNamesSection(llvm::Triple const&)::$_0>(long, llvm::dwarf_linker::parallel::DwarfUnit*) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
    #8 0x563e760be1b1 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
    #9 0x563e760be1b1 in forEachCompileAndTypeUnit /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp:1088:9
    #10 0x563e760be1b1 in llvm::dwarf_linker::parallel::DWARFLinkerImpl::emitDWARFv5DebugNamesSection(llvm::Triple const&) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp:1348:3
    #11 0x563e76778eb5 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__functional/function.h:430:12
    #12 0x563e76778eb5 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__functional/function.h:989:10
    #13 0x563e76778eb5 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:214:11
    #14 0x563e76778eb5 in __invoke<(lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:213:9) &> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__type_traits/invoke.h:150:25
    #15 0x563e76778eb5 in __call<(lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:213:9) &> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__type_traits/invoke.h:225:5
    #16 0x563e76778eb5 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__functional/function.h:171:12
    #17 0x563e76778eb5 in std::__1::__function::__func<llvm::parallel::TaskGroup::spawn(std::__1::function<void ()>, bool)::$_0, std::__1::allocator<llvm::parallel::TaskGroup::spawn(std::__1::function<void ()>, bool)::$_0>, void ()>::operator()() /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__functional/function.h:313:10
    #18 0x563e76774e92 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__functional/function.h:430:12
    #19 0x563e76774e92 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__functional/function.h:989:10
    #20 0x563e76774e92 in llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::work(llvm::ThreadPoolStrategy, unsigned int) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:141:7
    #21 0x563e767751e0 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:64:36
    #22 0x563e767751e0 in __invoke<(lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:64:30)> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__type_traits/invoke.h:150:25
    #23 0x563e767751e0 in __thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, (lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:64:30)> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__thread/thread.h:193:3
    #24 0x563e767751e0 in void* std::__1::__thread_proxy[abi:nn190000]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::ThreadPoolExecutor(llvm::ThreadPoolStrategy)::'lambda'()::operator()() const::'lambda'()>>(void*) /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__thread/thread.h:202:3
    #25 0x563e726d1646 in asan_thread_start(void*) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:239:28
    #26 0x7f0f03497b59  (/lib/x86_64-linux-gnu/libc.so.6+0x97b59) (BuildId: 502d55a5e424889ddb2846eb6dbeddaedd75b323)
    #27 0x7f0f035285fb  (/lib/x86_64-linux-gnu/libc.so.6+0x1285fb) (BuildId: 502d55a5e424889ddb2846eb6dbeddaedd75b323)
0x52100002d11c is located 28 bytes inside of 4096-byte region [0x52100002d100,0x52100002e100)
freed by thread T6 here:
    #0 0x563e7270b327 in operator delete(void*, unsigned long, std::align_val_t) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:173:3
    #1 0x563e7610a61d in Deallocate /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/Support/AllocatorBase.h:99:5
    #2 0x563e7610a61d in DeallocateSlabs /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/Support/Allocator.h:361:28
    #3 0x563e7610a61d in ~BumpPtrAllocatorImpl /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/Support/Allocator.h:98:5
    #4 0x563e7610a61d in llvm::dwarf_linker::parallel::CompileUnit::cloneAndEmit(std::__1::optional<std::__1::reference_wrapper<llvm::Triple const>>, llvm::dwarf_linker::parallel::TypeUnit*) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp:1288:1
    #5 0x563e760c96c8 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp:672:32
    #6 0x563e760c96c8 in llvm::Expected<bool> llvm::function_ref<llvm::Expected<bool> ()>::callback_fn<llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::linkSingleCompileUnit(llvm::dwarf_linker::parallel::CompileUnit&, llvm::dwarf_linker::parallel::TypeUnit*, llvm::dwarf_linker::parallel::CompileUnit::Stage)::$_0>(long) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
    #7 0x563e760b3643 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
    #8 0x563e760b3643 in llvm::dwarf_linker::finiteLoop(llvm::function_ref<llvm::Expected<bool> ()>, unsigned long) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/DWARFLinker/Utils.h:30:45
    #9 0x563e760b44c4 in llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::linkSingleCompileUnit(llvm::dwarf_linker::parallel::CompileUnit&, llvm::dwarf_linker::parallel::TypeUnit*, llvm::dwarf_linker::parallel::CompileUnit::Stage) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp:597:19
    #10 0x563e767790a9 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
    #11 0x563e767790a9 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:242:11
    #12 0x563e767790a9 in __invoke<(lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:240:16) &> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__type_traits/invoke.h:150:25
    #13 0x563e767790a9 in __call<(lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:240:16) &> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__type_traits/invoke.h:225:5
    #14 0x563e767790a9 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__functional/function.h:171:12
    #15 0x563e767790a9 in std::__1::__function::__func<llvm::parallelFor(unsigned long, unsigned long, llvm::function_ref<void (unsigned long)>)::$_0, std::__1::allocator<llvm::parallelFor(unsigned long, unsigned long, llvm::function_ref<void (unsigned long)>)::$_0>, void ()>::operator()() /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__functional/function.h:313:10
    #16 0x563e76778eb5 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__functional/function.h:430:12
    #17 0x563e76778eb5 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__functional/function.h:989:10
    #18 0x563e76778eb5 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:214:11
    #19 0x563e76778eb5 in __invoke<(lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:213:9) &> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__type_traits/invoke.h:150:25
    #20 0x563e76778eb5 in __call<(lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:213:9) &> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__type_traits/invoke.h:225:5
    #21 0x563e76778eb5 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__functional/function.h:171:12
    #22 0x563e76778eb5 in std::__1::__function::__func<llvm::parallel::TaskGroup::spawn(std::__1::function<void ()>, bool)::$_0, std::__1::allocator<llvm::parallel::TaskGroup::spawn(std::__1::function<void ()>, bool)::$_0>, void ()>::operator()() /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__functional/function.h:313:10
    #23 0x563e76774e92 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__functional/function.h:430:12
    #24 0x563e76774e92 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__functional/function.h:989:10
    #25 0x563e76774e92 in llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::work(llvm::ThreadPoolStrategy, unsigned int) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:141:7
    #26 0x563e767751e0 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:64:36
    #27 0x563e767751e0 in __invoke<(lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:64:30)> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__type_traits/invoke.h:150:25
    #28 0x563e767751e0 in __thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, (lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:64:30)> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__thread/thread.h:193:3
    #29 0x563e767751e0 in void* std::__1::__thread_proxy[abi:nn190000]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::ThreadPoolExecutor(llvm::ThreadPoolStrategy)::'lambda'()::operator()() const::'lambda'()>>(void*) /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__thread/thread.h:202:3
    #30 0x563e726d1646 in asan_thread_start(void*) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:239:28
previously allocated by thread T6 here:
    #0 0x563e7270a4e2 in operator new(unsigned long, std::align_val_t) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/compiler-rt/lib/asan/asan_new_delete.cpp:98:3
    #1 0x563e7285836e in Allocate /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/Support/AllocatorBase.h:92:12
    #2 0x563e7285836e in StartNewSlab /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/Support/Allocator.h:344:42
    #3 0x563e7285836e in llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul, 128ul>::AllocateSlow(unsigned long, unsigned long, llvm::Align) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/Support/Allocator.h:200:5
    #4 0x563e7610d2e9 in Allocate /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/Support/Allocator.h:176:12
    #5 0x563e7610d2e9 in Allocate /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/Support/Allocator.h:214:12
    #6 0x563e7610d2e9 in operator new<llvm::MallocAllocator, 4096UL, 4096UL, 128UL> /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/Support/Allocator.h:448:20
    #7 0x563e7610d2e9 in get /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/CodeGen/DIE.h:850:12
    #8 0x563e7610d2e9 in createDIE /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/DWARFLinker/Parallel/DIEGenerator.h:32:17
    #9 0x563e7610d2e9 in llvm::dwarf_linker::parallel::CompileUnit::createPlainDIEandCloneAttributes(llvm::DWARFDebugInfoEntry const*, llvm::dwarf_linker::parallel::DIEGenerator&, unsigned long&, std::__1::optional<long>&, std::__1::optional<long>&) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp:1399:33
    #10 0x563e7610ac90 in llvm::dwarf_linker::parallel::CompileUnit::cloneDIE(llvm::DWARFDebugInfoEntry const*, llvm::StringMapEntry<std::__1::atomic<llvm::dwarf_linker::parallel::TypeEntryBody*>>*, unsigned long, std::__1::optional<long>, std::__1::optional<long>, llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul, 128ul>&, llvm::dwarf_linker::parallel::TypeUnit*) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp:1309:23
    #11 0x563e7610a20d in llvm::dwarf_linker::parallel::CompileUnit::cloneAndEmit(std::__1::optional<std::__1::reference_wrapper<llvm::Triple const>>, llvm::dwarf_linker::parallel::TypeUnit*) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp:1248:44
    #12 0x563e760c96c8 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp:672:32
    #13 0x563e760c96c8 in llvm::Expected<bool> llvm::function_ref<llvm::Expected<bool> ()>::callback_fn<llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::linkSingleCompileUnit(llvm::dwarf_linker::parallel::CompileUnit&, llvm::dwarf_linker::parallel::TypeUnit*, llvm::dwarf_linker::parallel::CompileUnit::Stage)::$_0>(long) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:45:12
    #14 0x563e760b3643 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
    #15 0x563e760b3643 in llvm::dwarf_linker::finiteLoop(llvm::function_ref<llvm::Expected<bool> ()>, unsigned long) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/DWARFLinker/Utils.h:30:45
    #16 0x563e760b44c4 in llvm::dwarf_linker::parallel::DWARFLinkerImpl::LinkContext::linkSingleCompileUnit(llvm::dwarf_linker::parallel::CompileUnit&, llvm::dwarf_linker::parallel::TypeUnit*, llvm::dwarf_linker::parallel::CompileUnit::Stage) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp:597:19
    #17 0x563e767790a9 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/STLFunctionalExtras.h:68:12
    #18 0x563e767790a9 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:242:11
    #19 0x563e767790a9 in __invoke<(lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:240:16) &> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__type_traits/invoke.h:150:25
    #20 0x563e767790a9 in __call<(lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:240:16) &> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__type_traits/invoke.h:225:5
    #21 0x563e767790a9 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__functional/function.h:171:12
    #22 0x563e767790a9 in std::__1::__function::__func<llvm::parallelFor(unsigned long, unsigned long, llvm::function_ref<void (unsigned long)>)::$_0, std::__1::allocator<llvm::parallelFor(unsigned long, unsigned long, llvm::function_ref<void (unsigned long)>)::$_0>, void ()>::operator()() /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__functional/function.h:313:10
    #23 0x563e76778eb5 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__functional/function.h:430:12
    #24 0x563e76778eb5 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__functional/function.h:989:10
    #25 0x563e76778eb5 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:214:11
    #26 0x563e76778eb5 in __invoke<(lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:213:9) &> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__type_traits/invoke.h:150:25
    #27 0x563e76778eb5 in __call<(lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:213:9) &> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__type_traits/invoke.h:225:5
    #28 0x563e76778eb5 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__functional/function.h:171:12
    #29 0x563e76778eb5 in std::__1::__function::__func<llvm::parallel::TaskGroup::spawn(std::__1::function<void ()>, bool)::$_0, std::__1::allocator<llvm::parallel::TaskGroup::spawn(std::__1::function<void ()>, bool)::$_0>, void ()>::operator()() /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__functional/function.h:313:10
    #30 0x563e76774e92 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__functional/function.h:430:12
    #31 0x563e76774e92 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__functional/function.h:989:10
    #32 0x563e76774e92 in llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::work(llvm::ThreadPoolStrategy, unsigned int) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:141:7
    #33 0x563e767751e0 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:64:36
    #34 0x563e767751e0 in __invoke<(lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:64:30)> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__type_traits/invoke.h:150:25
    #35 0x563e767751e0 in __thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, (lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:64:30)> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__thread/thread.h:193:3
    #36 0x563e767751e0 in void* std::__1::__thread_proxy[abi:nn190000]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::ThreadPoolExecutor(llvm::ThreadPoolStrategy)::'lambda'()::operator()() const::'lambda'()>>(void*) /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__thread/thread.h:202:3
    #37 0x563e726d1646 in asan_thread_start(void*) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:239:28
Thread T20 created by T1 here:
    #0 0x563e726b9331 in pthread_create /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:250:3
    #1 0x563e76774573 in __libcpp_thread_create /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__thread/support/pthread.h:182:10
    #2 0x563e76774573 in thread<(lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:64:30), 0> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__thread/thread.h:212:14
    #3 0x563e76774573 in construct<std::__1::thread, (lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:64:30)> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__memory/allocator.h:166:24
    #4 0x563e76774573 in construct<std::__1::thread, (lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:64:30), 0> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__memory/allocator_traits.h:319:9
    #5 0x563e76774573 in __construct_one_at_end<(lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:64:30)> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/vector:920:5
    #6 0x563e76774573 in emplace_back<(lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:64:30)> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/vector:1510:5
    #7 0x563e76774573 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:64:17
    #8 0x563e76774573 in __invoke<(lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:62:27)> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__type_traits/invoke.h:150:25
    #9 0x563e76774573 in __thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, (lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:62:27)> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__thread/thread.h:193:3
    #10 0x563e76774573 in void* std::__1::__thread_proxy[abi:nn190000]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::ThreadPoolExecutor(llvm::ThreadPoolStrategy)::'lambda'()>>(void*) /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__thread/thread.h:202:3
    #11 0x563e726d1646 in asan_thread_start(void*) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:239:28
Thread T1 created by T0 here:
    #0 0x563e726b9331 in pthread_create /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:250:3
    #1 0x563e767726d2 in __libcpp_thread_create /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__thread/support/pthread.h:182:10
    #2 0x563e767726d2 in thread<(lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:62:27), 0> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__thread/thread.h:212:14
    #3 0x563e767726d2 in ThreadPoolExecutor /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:62:15
    #4 0x563e767726d2 in llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::Creator::call() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:95:38
    #5 0x563e76767168 in llvm::ManagedStaticBase::RegisterManagedStatic(void* (*)(), void (*)(void*)) const /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/ManagedStatic.cpp:34:19
    #6 0x563e767715c9 in operator* /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/Support/ManagedStatic.h:89:7
    #7 0x563e767715c9 in getDefaultExecutor /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:180:53
    #8 0x563e767715c9 in llvm::parallel::getThreadCount() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:187:10
    #9 0x563e760a780f in PerThreadAllocator /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/Support/PerThreadBumpPtrAllocator.h:31:25
    #10 0x563e760a780f in LinkingGlobalData /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/DWARFLinker/Parallel/DWARFLinkerGlobalData.h:85:7
    #11 0x563e760a780f in llvm::dwarf_linker::parallel::DWARFLinkerImpl::DWARFLinkerImpl(std::__1::function<void (llvm::Twine const&, llvm::StringRef, llvm::DWARFDie const*)>, std::__1::function<void (llvm::Twine const&, llvm::StringRef, llvm::DWARFDie const*)>) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp:22:18
    #12 0x563e760a7500 in make_unique<llvm::dwarf_linker::parallel::DWARFLinkerImpl, std::__1::function<void (const llvm::Twine &, llvm::StringRef, const llvm::DWARFDie *)> &, std::__1::function<void (const llvm::Twine &, llvm::StringRef, const llvm::DWARFDie *)> &> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__memory/unique_ptr.h:620:30
    #13 0x563e760a7500 in llvm::dwarf_linker::parallel::DWARFLinker::createLinker(std::__1::function<void (llvm::Twine const&, llvm::StringRef, llvm::DWARFDie const*)>, std::__1::function<void (llvm::Twine const&, llvm::StringRef, llvm::DWARFDie const*)>) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/DWARFLinker/Parallel/DWARFLinker.cpp:19:10
    #14 0x563e727a3d93 in llvm::Error llvm::dwarfutil::linkDebugInfoImpl<llvm::dwarf_linker::parallel::DWARFLinker>(llvm::object::ObjectFile&, llvm::dwarfutil::Options const&, llvm::raw_pwrite_stream&) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp:336:7
    #15 0x563e727a39eb in llvm::dwarfutil::linkDebugInfo(llvm::object::ObjectFile&, llvm::dwarfutil::Options const&, llvm::raw_pwrite_stream&) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp:472:12
    #16 0x563e7270e679 in applyCLOptions /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp:451:21
    #17 0x563e7270e679 in main /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/tools/llvm-dwarfutil/llvm-dwarfutil.cpp:527:11
    #18 0x7f0f0342814f  (/lib/x86_64-linux-gnu/libc.so.6+0x2814f) (BuildId: 502d55a5e424889ddb2846eb6dbeddaedd75b323)
Thread T6 created by T1 here:
    #0 0x563e726b9331 in pthread_create /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:250:3
    #1 0x563e76774573 in __libcpp_thread_create /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__thread/support/pthread.h:182:10
    #2 0x563e76774573 in thread<(lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:64:30), 0> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__thread/thread.h:212:14
    #3 0x563e76774573 in construct<std::__1::thread, (lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:64:30)> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__memory/allocator.h:166:24
    #4 0x563e76774573 in construct<std::__1::thread, (lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:64:30), 0> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__memory/allocator_traits.h:319:9
    #5 0x563e76774573 in __construct_one_at_end<(lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:64:30)> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/vector:920:5
    #6 0x563e76774573 in emplace_back<(lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:64:30)> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/vector:1510:5
    #7 0x563e76774573 in operator() /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:64:17
    #8 0x563e76774573 in __invoke<(lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:62:27)> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__type_traits/invoke.h:150:25
    #9 0x563e76774573 in __thread_execute<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct> >, (lambda at /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Parallel.cpp:62:27)> /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__thread/thread.h:193:3
    #10 0x563e76774573 in void* std::__1::__thread_proxy[abi:nn190000]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, llvm::parallel::detail::(anonymous namespace)::ThreadPoolExecutor::ThreadPoolExecutor(llvm::ThreadPoolStrategy)::'lambda'()>>(void*) /b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/__thread/thread.h:202:3
    #11 0x563e726d1646 in asan_thread_start(void*) /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/compiler-rt/lib/asan/asan_interceptors.cpp:239:28
SUMMARY: AddressSanitizer: heap-use-after-free /b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/CodeGen/DIE.h:855:38 in getTag
Shadow bytes around the buggy address:
  0x52100002ce80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x52100002cf00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x52100002cf80: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x52100002d000: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x52100002d080: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x52100002d100: fd fd fd[fd]fd fd fd fd fd fd fd fd fd fd fd fd
  0x52100002d180: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x52100002d200: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x52100002d280: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x52100002d300: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x52100002d380: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==120988==ABORTING

fmayer added a commit that referenced this pull request Jun 12, 2024
fmayer added a commit that referenced this pull request Jun 12, 2024
…95302)

Reverts #95039

This looks like it caused the ASan bot to fail:
https://lab.llvm.org/buildbot/#/builders/168/builds/20912

Offending line was changed in this PR
@ayermolo
Copy link
Contributor Author

ayermolo commented Jun 12, 2024

Thanks for flagging.
Looks like issue is in: llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp

DebugNames->addName(
            *DebugStrStrings.getExistingEntry(Info.String), Info.OutOffset,
            std::nullopt /*ParentDIEOffset*/, Info.Tag, CU->getUniqueID(),
            CU->getOutUnitDIE()->getTag() == dwarf::DW_TAG_type_unit);

Passing false instead fixes asan.

The UnitDie is getting set in CompileUnit::cloneAndEmit. After it gets cloned using local Allocator.

Maybe worth resetting to nullptr at the end?

@fmayer
Copy link
Contributor

fmayer commented Jun 12, 2024

Passing false to what exactly?

@ayermolo
Copy link
Contributor Author

ayermolo commented Jun 12, 2024

Passing false to what exactly?

to DebugNames->addName, instead of CU->getOutUnitDIE()->getTag() == dwarf::DW_TAG_type_unit.

Basically issue was I was accessing getOutUnitDIE which was allocated local BumpAllocator in CompileUnit::cloneAndEmit. So memory was garbage.

To be clear passing false always is not a fix. It was just a quick test.

@ayermolo
Copy link
Contributor Author

Fixed asan: #95339

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

debug_names incorrect parent due to collision between CU and TU
5 participants