[PATCH] D128184: [lld-macho] Show source information for undefined references

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 21 06:09:33 PDT 2022


thakis added a comment.

In D128184#3597967 <https://reviews.llvm.org/D128184#3597967>, @BertalanD wrote:

> Looks like `ObjFile::parseDebugInfo` wasn't checking if there were any compilation units before assigning the iterator's value to `compileUnit`. I'm not sure why that didn't cause issues previously, it's maybe because we were taking slightly different code paths as we did not parse `__debug_line`.

I think your `__debug_line` theory has legs. If I take the original patch and change just this:

   % git diff
  diff --git a/lld/MachO/Dwarf.cpp b/lld/MachO/Dwarf.cpp
  index 357503a655cd..24a6530795dd 100644
  --- a/lld/MachO/Dwarf.cpp
  +++ b/lld/MachO/Dwarf.cpp
  @@ -29,7 +29,7 @@ std::unique_ptr<DwarfObject> DwarfObject::create(ObjFile *obj) {
       if (StringRef *s =
               StringSwitch<StringRef *>(isec->getName())
                   .Case(section_names::debugInfo, &dObj->infoSection.Data)
  -                .Case(section_names::debugLine, &dObj->lineSection.Data)
  +                //.Case(section_names::debugLine, &dObj->lineSection.Data)
                   .Case(section_names::debugAbbrev, &dObj->abbrevSection)
                   .Case(section_names::debugStr, &dObj->strSection)
                   .Default(nullptr)) {

…then my repro case no longer crashes.

So dereferencing end() happens to produce nullptr before by dumb luck, but doesn't after. And scarily, we don't have anything that catches us derefing end() in this scenario.


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

https://reviews.llvm.org/D128184



More information about the llvm-commits mailing list