This is an archive of the discontinued LLVM Phabricator instance.

Return an error when the CFA resolves to no known register, instead of segfaulting
ClosedPublic

Authored by jasonmolenda on Feb 2 2023, 4:48 PM.

Details

Summary

I'm working on a bug report where lldb crashes while trying to read the register that is used to calculate the canonical frame address for the first frame in a stack trace. I haven't figured out how they're getting in this state yet, but I want to add a check for a failure to find a register in this case, and declare the stack frame as invalid to handle the error. I also added an assert so we can catch it early in debug builds if it ever comes up here.

I think returning no valid stack frame for this thread is going to be a better failure mode than having the debugger crash out from under them, ending the debug session. It's still a pretty bad failure, but hopefully we can collect some logging with this if it comes up again.

Diff Detail

Event Timeline

jasonmolenda created this revision.Feb 2 2023, 4:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 2 2023, 4:48 PM
jasonmolenda requested review of this revision.Feb 2 2023, 4:48 PM
bulbazord accepted this revision.Feb 2 2023, 5:27 PM

LGTM. I wonder if there's a good way to exercise this with a test? Like maybe we can create some bogus unwind information and see if LLDB falls over when consuming it?

This revision is now accepted and ready to land.Feb 2 2023, 5:27 PM

LGTM. I wonder if there's a good way to exercise this with a test? Like maybe we can create some bogus unwind information and see if LLDB falls over when consuming it?

I'm not sure how we could do that tbh - the currently executing frame uses an unwind plan sourced from the assembly instructions, and I can't construct assembly language that lldb would parse as using an invalid register number to calculate the canonical frame address. (I genuinely have no idea how we're hitting this codepath; it should not be possible.)