Skip to content

[dsymutil] --linker=parallel causes self-recurring typedef in DIE for std::string #162954

@royitaqi

Description

@royitaqi

TL;DR

When running dsymutil --linker=parallel, the generated dSYM contains a DIE (see below), which is a typedef of itself (the address of the DW_TAG_typedef is identical to that of the DW_AT_type).

0x00004cb1: DW_TAG_typedef
              DW_AT_type	(0x00004cb1 "string")
              DW_AT_name	("string")
              DW_AT_decl_line	(45)
              DW_AT_decl_file	("/Applications/Xcode_26.0.0_17A324_fb.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/v1/__fwd/string.h")

Notes:

  • This happens on macOS. Not sure if it happens on other OS.
  • This causes LLDB to enter infinite recursion when trying to understand this type. See stack trace. See "Step 2" below.
  • dsymutil --verify-dwarf=all doesn't report this issue.
  • This issue doesn't happen without --linker=parallel. See "Step 3" below.

Repro steps on macOS

Step 1: Create the following main.cpp:

#include <string>
#include <iostream>

int main() {
  std::string f = "Hello World";
  std::cout << f << std::endl;
}

Step 2: Run dsymutil WITH --linker=parallel to repro the issue:

xcrun clang++ -g -O0 -c main.cpp
xcrun clang++ -g -O0 main.o
~/public_llvm/build/bin/dsymutil --verify-dwarf=all --linker=parallel -o a.out.dSYM a.out
dwarfdump a.out.dSYM --name=string
lldb a.out -o "b main.cpp:6" -o "r" -o "p f"

I see these output: https://gist.github.com/royitaqi/1afb74beccfcd011021e339e1dc76e0d

Observe:

  • The DIE contains a "string" which is a typedef of itself.
  • The --verify-dwarf=all doesn't catch this issue.
  • If you attach an lldb to the above lldb, you will see the above call stack.

(optional) Step 3: Run dsymutil WITHOUT --linker=parallel as a comparison:

xcrun clang++ -g -O0 -c main.cpp
xcrun clang++ -g -O0 main.o
~/public_llvm/build/bin/dsymutil --verify-dwarf=all -o a.out.dSYM a.out
dwarfdump a.out.dSYM --name=string
lldb a.out -o "b main.cpp:6" -o "r" -o "p f"

I see these output: https://gist.github.com/royitaqi/e83bb8b986fef3556f2e268e8c7a6eee

Observe:

  • The DIE contains one "string" which is a typedef of another "string", which is the actual std::basic_string.
  • The "string" type is understood and is printed correctly by lldb.

--

cc @clayborg

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions