Fix duplicated frames in stack traces #335
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the change
This PR fixes two issues in which frames would appear duplicated.
The duplication error occurs at some point during the handling of a crash, when the signal has been emitted and the mach-o
EXC_BAD_ACCESS
exception has been formed, I suspect this is a tail call optimization messing with stack frames, similar to kstenerud/KSCrash#379.The very nature of a crash hook makes debugging it extremely convoluted to the point it requires modifying lldb (llvm's debugger) code and compiling a custom version. This is because we must make lldb ignore certain types of mach-o signals and let the crashing program run, at which point it would trigger our hook, and a breakpoint there.
Resorting to logging also makes this very difficult since this issue happens in optimized builds, when the crash originates in the iPhone, so, we have nowhere to log out at that point without a debugger, and logging to the AUL (Apple Unified Logging) is time consuming and the crash hook only has a few ms to live.
This issue exists on both Sentry and Bugsnag, they deal with it server-side. I believe dealing with it as close to the source as possible is better. The crash report we send to Rollbar, should be the same the OS provides users, it shouldn't be corrupted.
That led me to create a fixup that simply dedups the reports hen the conditions have been met as they're being loaded.
Condition 1)
Exception address and subcode are the same, they match the instruction address of the first frame in the crashed thread, and the second frame is identical to the first one. We remove one of those frames.
Condition 2)
Register
lr
(link register) is identical to the instruction address of the last frame in a thread, and the last two frames are identical, we remove one of those frames.Before/After
Before 1
Before 2
After
Part of:
Type of change
Checklists
Development
Code review