This is an archive of the discontinued LLVM Phabricator instance.

Fix a crash in DWARFUnit::getInlinedChainForAddress in case of unexpected DWARF information.
ClosedPublic

Authored by aorlov on Mar 6 2021, 10:27 AM.

Details

Summary

In some cases a broken or invalid debug info could cause a crash in DWARFUnit::getInlinedChainForAddress during parsing a chain of in-lined functions. This patch fixes this issue.

Diff Detail

Event Timeline

aorlov created this revision.Mar 6 2021, 10:27 AM
aorlov requested review of this revision.Mar 6 2021, 10:27 AM

This'll need a test case

aorlov updated this revision to Diff 329051.Mar 8 2021, 9:44 AM
aorlov retitled this revision from Avoid infinite loop in DWARFUnit::getInlinedChainForAddress in case of unexpected DWARF information. to Fix a crash in DWARFUnit::getInlinedChainForAddress in case of unexpected DWARF information..
aorlov edited the summary of this revision. (Show Details)

I have added the test file.

dblaikie accepted this revision.Mar 8 2021, 3:11 PM

Seems good enough - though if you're interested in this code being able to handle arbitrarily broken DWARF, this function probably needs to be changed to be able to return some kind of failure (like llvm::Error) for the case where the parent walk reaches DIE types that would never be found in the usual scope chain (ie: something other than inlined_subroutines and lexical_blocks (or lexical_scopes, I can never remember the right tag name)) - because the caller's probably going to be pretty confused by other DIEs appearing in this list.

This revision is now accepted and ready to land.Mar 8 2021, 3:11 PM
This revision was landed with ongoing or failed builds.Mar 9 2021, 2:21 AM
This revision was automatically updated to reflect the committed changes.