[PATCH] D132900: [DWARF] Fix infinite recursion in Type Printer.
Alexander Yermolovich via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 29 17:49:31 PDT 2022
ayermolo created this revision.
Herald added subscribers: hoy, modimo, wenlei, hiraditya.
Herald added a project: All.
ayermolo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
There is an implicit circular dependency in a debug information coming from GCC.
This results in a coredump.
0x0066ec56: DW_TAG_formal_parameter [3] (0x0066ec48)
DW_AT_type [DW_FORM_ref4] (cu + 0x168fa => {0x0066ec5b}
"
appendQualifiedName: 66ec5b
appendScopes: 66ec48
appendUnqualifiedName: 66ec48
appendUnqualifiedNameBefore: 66ec48
appendQualifiedNameBefore: 66597f
appendScopes: 665972
appendScopes: 65838b
appendUnqualifiedName: 65838b
appendUnqualifiedNameBefore: 65838b
sappendUnqualifiedNameAfter: 65838b
appendUnqualifiedName: 665972
appendUnqualifiedNameBefore: 665972
appendUnqualifiedNameAfter: 665972
appendUnqualifiedNameBefore: 66597f
appendUnqualifiedNameAfter: 66ec48
appendUnqualifiedName: 66ec48
appendQualifiedName: 66ec5b
appendScopes: 66ec48
TBH not sure if this is the correct fix or not.
Thoughts appreciated.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D132900
Files:
llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h
llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
Index: llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFTypePrinter.cpp
@@ -283,8 +283,12 @@
}
void DWARFTypePrinter::appendQualifiedName(DWARFDie D) {
- if (D)
+ if (D) {
+ if (CircularDep.contains(D.getOffset()))
+ return;
+ CircularDep.insert(D.getOffset());
appendScopes(D.getParent());
+ }
appendUnqualifiedName(D);
}
DWARFDie DWARFTypePrinter::appendQualifiedNameBefore(DWARFDie D) {
Index: llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h
===================================================================
--- llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h
+++ llvm/include/llvm/DebugInfo/DWARF/DWARFTypePrinter.h
@@ -9,6 +9,7 @@
#ifndef LLVM_DEBUGINFO_DWARF_DWARFTYPEPRINTER_H
#define LLVM_DEBUGINFO_DWARF_DWARFTYPEPRINTER_H
+#include "llvm/ADT/SmallSet.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/DebugInfo/DWARF/DWARFDie.h"
@@ -25,6 +26,7 @@
raw_ostream &OS;
bool Word = true;
bool EndedWithTemplate = false;
+ SmallSet<uint64_t, 5> CircularDep;
DWARFTypePrinter(raw_ostream &OS) : OS(OS) {}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132900.456506.patch
Type: text/x-patch
Size: 1257 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220830/7809fb3f/attachment.bin>
More information about the llvm-commits
mailing list