This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Fix image lookup crash
ClosedPublic

Authored by bulbazord on Feb 10 2023, 4:13 PM.

Details

Summary

lldb may crash when performing image lookup --verbose --address $ADDR.
The ExecutionContext that gets passed into DWARFExpression::Evaluate may
be valid but unpopulated. However, in one specific case, we were
assuming that it has a valid Target and using it without checking first.

We reach this codepath when we attempt to get information about an
address that doesn't map to a CompileUnit in the module containing the
requested address. lldb then checks to see if it maps to a global
variable, so lldb has to evaluate the location of each global variable
in the module. If a location expression contains DW_OP_deref_size that
uses a FileAddress, we hit this code path. The simplest test case is to
take a module that has a global variable with DW_OP_deref_size in its
location expression, attempt to read an address that doesn't map to a
CompileUnit (e.g. 0x0) and ensure we don't crash.

rdar://105220281

Diff Detail

Event Timeline

bulbazord created this revision.Feb 10 2023, 4:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 10 2023, 4:13 PM
bulbazord requested review of this revision.Feb 10 2023, 4:13 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 10 2023, 4:13 PM
bulbazord edited the summary of this revision. (Show Details)Feb 10 2023, 4:33 PM
mib accepted this revision.Feb 10 2023, 4:40 PM

LGTM!

This revision is now accepted and ready to land.Feb 10 2023, 4:40 PM
JDevlieghere accepted this revision.Feb 10 2023, 5:02 PM
This revision was automatically updated to reflect the committed changes.