Skip to content

Commit

Permalink
fix(ndk): remove possibility the the bsg_global_env->handling_crash
Browse files Browse the repository at this point in the history
… or `unwinding_crash_stack` CAS succeed spuriously
  • Loading branch information
lemnik committed Jan 8, 2024
1 parent ba43ff7 commit 82a838a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## TBD

### Bug fixes

* Avoid any possibility of multiple conflicting native crash handlers or stack-unwinders running concurrently
[#1960](https://github.com/bugsnag/bugsnag-android/pull/1960)

## 6.1.0 (2023-12-05)

### Enhancements
Expand Down
2 changes: 1 addition & 1 deletion bugsnag-plugin-android-ndk/src/main/jni/bugsnag_ndk.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ bool bsg_run_on_error() {
}

bool bsg_begin_handling_crash() {
static bool expected = false;
bool expected = false;
return atomic_compare_exchange_strong(&bsg_global_env->handling_crash,
&expected, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ ssize_t bsg_unwind_crash_stack(bugsnag_stackframe stack[BUGSNAG_FRAMES_MAX],
// we always check unwinding_crash_stack and set *before* attempting to
// retrieve the crash unwinder to avoid picking up an unwinder that is about
// to be destroyed by bsg_unwinder_refresh
static bool expected = false;
bool expected = false;
if (!std::atomic_compare_exchange_strong(&unwinding_crash_stack, &expected,
true)) {
return 0;
Expand Down

0 comments on commit 82a838a

Please sign in to comment.