[llvm] [gsymutil] Fix crash caused by infinite recursion in `unwrapReferencedTypedefType()` (PR #196448)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Fri May 8 11:02:30 PDT 2026


================
@@ -169,8 +169,10 @@ const char *toString(std::optional<DWARFFormValueType> F) {
 }
 
 /// Resolve the DW_AT_type of \c D until we reach a DIE that is not a
-/// DW_TAG_typedef.
-template <typename DieType> DieType unwrapReferencedTypedefType(DieType D) {
+/// DW_TAG_typedef. Gives up after 256 typedefs to guard against cycles in
+/// malformed DWARF.
+template <typename DieType>
+DieType unwrapReferencedTypedefType(DieType D, unsigned Depth = 256) {
----------------
dwblaikie wrote:

Yeah, I'd be somewhat more inclined towards a map (well, a set).

Also perhaps this could be rewritten as a loop, which would make it a bit cheaper on deep nesting?

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


More information about the llvm-commits mailing list