This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Add missing nullptr checks to AppleObjCRuntime::GetBacktraceThreadFromException
ClosedPublic

Authored by teemperor on Apr 24 2020, 12:29 AM.

Details

Summary

We got a few crash reports where LLDB crashes while derefencing the frames_value shared_ptr in the AppleObjCRuntime::GetBacktraceThreadFromException. GetChildMemberWithName returns a nullptr when an error occurs, so this seems to be just a missing nullptr check.

This patch adds that nullptr check and the other ones in the similar code directly below.

Fixes rdar://62174039

Diff Detail

Event Timeline

teemperor created this revision.Apr 24 2020, 12:29 AM

I don't know the code well enough to know how to reach a state where we can't find the _frames member, so I haven't found a test for this yet. If anyone has an idea how to reach that then let me know.

Yes, we shouldn't fall over if we can't get the exception backtrace out of the exception message.

You should be able to make an NSException that has a callStackReturnAddresses dictionary entry that doesn't contain these fields. So I think you can write a test for this, though the patch is also clearly right...

It makes me a little unhappy that all the errors in this function silently return an empty thread, so we're never going to know why this fails... If there was some way to add useful logging to this function, that would be great.

teemperor updated this revision to Diff 262596.May 7 2020, 3:53 AM
  • Add logging to all the error cases.

Still figuring out the test.

jingham accepted this revision.May 7 2020, 10:41 AM

Excellent, thanks!

This revision is now accepted and ready to land.May 7 2020, 10:41 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMay 11 2020, 7:29 AM