This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Prevent crash when reporting error messages if debug line cannot be parsed
ClosedPublic

Authored by jhenderson on Mar 7 2018, 6:03 AM.

Details

Summary

I noticed this whilst doing some work on the debug line parser. LLD uses the debug info and debug line sections to determine the location of e.g. references to undefined symbols, when producing error messages. In the event that debug info was present, but debug line parsing failed for some reason, then a nullptr would end up being dereferenced by the location-lookup code.

Diff Detail

Repository
rL LLVM

Event Timeline

jhenderson created this revision.Mar 7 2018, 6:03 AM
grimar added inline comments.Mar 7 2018, 6:12 AM
ELF/InputFiles.cpp
149 ↗(On Diff #137373)

If there any reason why it cannot be early returned above?

const DWARFDebugLine::LineTable *LT =
    DwarfLine->getOrParseLineTable(LineData, 0, Dwarf, nullptr);
if (!LT)
  return;
jhenderson added inline comments.Mar 7 2018, 6:16 AM
ELF/InputFiles.cpp
149 ↗(On Diff #137373)

Good point - not that I can think of.

jhenderson updated this revision to Diff 137379.Mar 7 2018, 6:26 AM

Return early as suggested.

grimar accepted this revision.Mar 7 2018, 6:33 AM

LGTM

This revision is now accepted and ready to land.Mar 7 2018, 6:33 AM
This revision was automatically updated to reflect the committed changes.