Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix duplicated frames in stack traces #335

Merged
merged 4 commits into from
Aug 16, 2023
Merged

Fix duplicated frames in stack traces #335

merged 4 commits into from
Aug 16, 2023

Conversation

matux
Copy link
Collaborator

@matux matux commented Aug 10, 2023

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

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Maintenance
  • New release

Checklists

Development

  • Lint rules pass locally
  • The code changed/added as part of this pull request has been covered with tests
  • All tests related to the changed code pass in development

Code review

  • This pull request has a descriptive title and information useful to a reviewer. There may be a screenshot or screencast attached
  • "Ready for review" label attached to the PR and reviewers assigned
  • Issue from task tracker has a link to this pull request
  • Changes have been reviewed by at least one other engineer

@matux matux self-assigned this Aug 10, 2023
Copy link
Contributor

@waltjones waltjones left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@matux matux merged commit 9730c9a into master Aug 16, 2023
1 check passed
@matux matux deleted the dedup2 branch August 16, 2023 18:09
@shortcut-integration
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants