This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Make debug line address size mismatch non-fatal to parsing
ClosedPublic

Authored by jhenderson on Jan 3 2020, 7:33 AM.

Details

Summary

Reasonable assumptions can be made when a parsed address length does not match the expected length, so there's no need for this to be fatal.

Diff Detail

Event Timeline

jhenderson created this revision.Jan 3 2020, 7:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 3 2020, 7:33 AM
Herald added a subscriber: hiraditya. · View Herald Transcript

Early ping - I'd like to get this and the other related reviews in before the release branch is created if possible.

ikudrin added inline comments.Jan 9 2020, 4:49 AM
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
9–1

I find these lines a bit hard to follow, without prior understanding of the whole idea. I would suggest reorganize them like this:

uint8_t ExtractorAddressSize = DebugLineData.getAddressSize();
if (ExtractorAddressSize != Len - 1) {
  RecoverableErrorCallback(...);
}
// Assuming that the line table is correct, temporarily override the address size.
DebugLineData.setAddressSize(Len - 1);
State.Row.Address.Address = ...
// Restore the address size if the extractor already had it.
if (ExtractorAddressSize != 0)
  DebugLineData.setAddressSize(ExtractorAddressSize);

What do you think?

jhenderson marked an inline comment as done.Jan 9 2020, 5:04 AM
jhenderson added inline comments.
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
9–1

Yes, I think that should work, with one minor change to the error check - a value of zero from the extractor shouldn't cause an error. I'll try that.

jhenderson updated this revision to Diff 237028.Jan 9 2020, 5:11 AM
jhenderson marked an inline comment as done.

Address review comment.

ikudrin accepted this revision.Jan 13 2020, 7:04 AM

LGTM. Sorry for the delay.

This revision is now accepted and ready to land.Jan 13 2020, 7:04 AM

LGTM. Sorry for the delay.

No problem. Thanks for the review!

This revision was automatically updated to reflect the committed changes.
ikudrin added inline comments.Jan 30 2020, 12:17 AM
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
621

@jhenderson, it looks like that an incorrect Len value, i. e. not 1, 2, 4 or 8, eventually leads to a crash in DataExtractor::getUnsigned(). Please add a patch to check that case.

jhenderson marked an inline comment as done.Jan 30 2020, 1:05 AM
jhenderson added inline comments.
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
621

Will do!

jhenderson marked an inline comment as done.Feb 4 2020, 6:16 AM
jhenderson added inline comments.
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
621

Patch put up for review in D73962.