Skip to content

Commit 3b3b5e2

Browse files
jpnurmiclaude
andcommitted
fix(inproc): disable CHAIN_AT_START on Android API < 26
On Android API < 26, the old debuggerd daemon kills the crashing process via SIGKILL after the chained signal handler triggers it. CHAIN_AT_START cannot regain control after invoking the previous handler, so fall back to DEFAULT which chains at the end instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 176d4af commit 3b3b5e2

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

src/backends/sentry_backend_inproc.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
# include <poll.h>
2828
#endif
2929
#ifdef SENTRY_PLATFORM_ANDROID
30+
# include <android/api-level.h>
3031
# include <sys/syscall.h>
3132
#endif
3233
#include <string.h>
@@ -1550,9 +1551,20 @@ dispatch_ucontext(const sentry_ucontext_t *uctx,
15501551
static void
15511552
process_ucontext(const sentry_ucontext_t *uctx)
15521553
{
1554+
sentry_handler_strategy_t strategy = g_backend_config.handler_strategy;
1555+
#ifdef SENTRY_PLATFORM_ANDROID
1556+
// CHAIN_AT_START invokes the previous handler and expects to regain
1557+
// control. On Android API < 26, the old debuggerd daemon kills the
1558+
// crashing process via SIGKILL after the chained handler triggers
1559+
// it, so we fall back to DEFAULT which chains at the end instead.
1560+
if (strategy == SENTRY_HANDLER_STRATEGY_CHAIN_AT_START
1561+
&& android_get_device_api_level() < 26) {
1562+
strategy = SENTRY_HANDLER_STRATEGY_DEFAULT;
1563+
}
1564+
#endif
1565+
15531566
#ifdef SENTRY_PLATFORM_LINUX
1554-
if (g_backend_config.handler_strategy
1555-
== SENTRY_HANDLER_STRATEGY_CHAIN_AT_START
1567+
if (strategy == SENTRY_HANDLER_STRATEGY_CHAIN_AT_START
15561568
&& uctx->signum != SIGABRT) {
15571569
// SIGABRT is excluded: CLR/Mono never uses it for managed exception
15581570
// translation. Chaining SIGABRT to a SIG_DFL previous handler calls
@@ -1688,8 +1700,7 @@ process_ucontext(const sentry_ucontext_t *uctx)
16881700
sentry__atomic_store(&g_crash_handling_state, CRASH_STATE_DONE);
16891701

16901702
sentry__leave_signal_handler();
1691-
if (g_backend_config.handler_strategy
1692-
!= SENTRY_HANDLER_STRATEGY_CHAIN_AT_START) {
1703+
if (strategy != SENTRY_HANDLER_STRATEGY_CHAIN_AT_START) {
16931704
invoke_signal_handler(
16941705
uctx->signum, uctx->siginfo, (void *)uctx->user_context);
16951706
}

0 commit comments

Comments
 (0)