This is an archive of the discontinued LLVM Phabricator instance.

[lldb-vscode] Don't call SBValue.GetError after generating a summary.
ClosedPublic

Authored by jgorbe on Oct 27 2022, 2:54 PM.

Details

Summary

In some occasions, SBValue::GetError can invalidate its cached
m_summary_str member. This in turn invalidates any StringRef variables
pointing to it.

Diff Detail

Event Timeline

jgorbe created this revision.Oct 27 2022, 2:54 PM
Herald added a project: Restricted Project. · View Herald TranscriptOct 27 2022, 2:54 PM
clayborg accepted this revision.Oct 27 2022, 3:03 PM

Looks good!

This revision is now accepted and ready to land.Oct 27 2022, 3:03 PM
yinghuitan added inline comments.Oct 27 2022, 4:11 PM
lldb/tools/lldb-vscode/JSONUtils.cpp
143

Sorry for the late comment. The fix is fine but it depends on an important assumption that GetError() has to be called before GetSummary(). Can we add an explicit comment to document this so that future refactoring won't violate it again.

clayborg added inline comments.Oct 27 2022, 4:17 PM
lldb/tools/lldb-vscode/JSONUtils.cpp
143

We shouldn't, we need to fix this API bug in LLDB itself. Just calling SBValue::GetError() shouldn't end up clearing the m_summary_str IMHO. This seems like the real bug. This is working around this. IF we add a comment, it won't end up being true when we fix the issue.