[PATCH] D94976: [DWARF] Create subprogram's DIE in the unit specified by its DISubprogram

Jeremy Morse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 3 09:21:11 PST 2021


jmorse updated this revision to Diff 321115.
jmorse added a comment.

Re-opening this as D95622 <https://reviews.llvm.org/D95622> reverted it, because using type units led to various crashes and assertions. My revision to this patch just disables the new behaviour (created subprograms in their preferred unit) when using type units.

Here's a reduced reproducer that crashes for me with clang `-O3 -g -mllvm -generate-type-units -c`.

  enum a {};
  inline a b() {
    auto c = [] {};
  }
  void d(int) { b; }

I believe the type for lambda "c" is placed in a type unit. The type unit creates the scope of the lambda (subprogram "b") , the DIE for which is placed in the normal compile unit with this patch applied. However, the type information added to the subprogram to complete the type unit comes from that type units bump allocator pool. The result is that when the type unit is disposed of, the subprogram in the normal compile unit has children in freed memory. This annoys asan, which reports a use-after-free.

Using the old behaviour for type units seems to work just fine, `DwarfUnit::isShareableAcrossCUs` already disallows subprogram sharing when type units are used, which my change to. I continue to worry that there's more hidden beneath the surface here :(


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94976/new/

https://reviews.llvm.org/D94976

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/test/DebugInfo/X86/subprogram-across-cus.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94976.321115.patch
Type: text/x-patch
Size: 7349 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210203/d750d89f/attachment.bin>


More information about the llvm-commits mailing list