This is an archive of the discontinued LLVM Phabricator instance.

Fix crash in lldb-vscode when missing function name
ClosedPublic

Authored by zhyty on Aug 3 2023, 12:46 AM.

Details

Summary

In cases where the PC has no function name, lldb-vscode crashes.

lldb::SBFrame::GetDisplayFunctionName() returns a nullptr, and when we
attempt to construct an std::string, it raises an exception.

Test plan:
This can be observed with creating a test file (credit to @clayborg for the
example):

int main() {
  typedef void (*FooCallback)();
  FooCallback foo_callback = (FooCallback)0;
  foo_callback(); // Crash at zero!
  return 0;
}

and attempting to debug the file through VSCode.

I will add a test case in D156732 which should cover this.

Diff Detail

Event Timeline

zhyty created this revision.Aug 3 2023, 12:46 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2023, 12:46 AM
zhyty requested review of this revision.Aug 3 2023, 12:46 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2023, 12:46 AM
zhyty edited the summary of this revision. (Show Details)Aug 3 2023, 12:47 AM
kusmour accepted this revision.Aug 3 2023, 10:44 AM
This revision is now accepted and ready to land.Aug 3 2023, 10:44 AM
This revision was automatically updated to reflect the committed changes.
clayborg added inline comments.Aug 9 2023, 2:40 PM
lldb/tools/lldb-vscode/JSONUtils.cpp
699–703