[PLAT-6163] Fix recrash deadlocks #1252
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.
Goal
Fix deadlocks that could occur if the crash handling code (or the app's
onCrashHandler
callback) crashes.Changeset
context->reservedThreads
being clobbered inbsg_kscrashsentry_clearContext()
.thread_terminate
being called on original crashing thread when handling a nested Mach exception.bsg_kscrashsentry_beginHandlingCrash()
is called when an unhandledNSException
is detected, so that crashes during crash handling can be identified.There remains a deadlock on macOS 10.14 and earlier if a signal handler crashes. This appears to be a bug in the OS and not something we can work around.
Sample code
Testing
E2E tests have been set up on a separate branch (will be included in a future PR) and passed on CI: https://buildkite.com/bugsnag/bugsnag-cocoa/builds/4195