This is an archive of the discontinued LLVM Phabricator instance.

[lldb/API] Fix the dangling pointer issue in SBThread::GetStopDescription
AbandonedPublic

Authored by mib on Feb 5 2020, 3:39 PM.

Details

Summary

Instead of creating a char pointer to hold the stop reason description,
the reason is stored in a std::string.

Diff Detail

Event Timeline

mib created this revision.Feb 5 2020, 3:39 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 5 2020, 3:39 PM
friss added inline comments.Feb 5 2020, 3:47 PM
lldb/source/API/SBThread.cpp
361–363

I don't think this is generally safe. Creating a std::string from a nullptr is undefined (and the previous test makes it look like this pointer could be null).

JDevlieghere added inline comments.Feb 5 2020, 3:54 PM
lldb/source/API/SBThread.cpp
361–363

GetStopDescription now returns a std::string, so it should be fine here?

JDevlieghere added inline comments.Feb 5 2020, 3:59 PM
lldb/source/API/SBThread.cpp
357

This looks like some "optimization" to not have to compute the strlen below if the string is known. I dont't think we need this anymore with the description being a string?

394

You could simplify this

if (!stop_desc.empty() && dst) {
mib added a reviewer: labath.Feb 5 2020, 4:10 PM
JDevlieghere added inline comments.Feb 5 2020, 4:10 PM
lldb/source/API/SBThread.cpp
361–363

nvm, I didn't see the variable got assigned again

mib abandoned this revision.Feb 6 2020, 6:10 AM

I'll merge this with D73303