|
27 | 27 | # include <poll.h> |
28 | 28 | #endif |
29 | 29 | #ifdef SENTRY_PLATFORM_ANDROID |
| 30 | +# include <android/api-level.h> |
30 | 31 | # include <sys/syscall.h> |
31 | 32 | #endif |
32 | 33 | #include <string.h> |
@@ -1550,9 +1551,20 @@ dispatch_ucontext(const sentry_ucontext_t *uctx, |
1550 | 1551 | static void |
1551 | 1552 | process_ucontext(const sentry_ucontext_t *uctx) |
1552 | 1553 | { |
| 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 | + |
1553 | 1566 | #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 |
1556 | 1568 | && uctx->signum != SIGABRT) { |
1557 | 1569 | // SIGABRT is excluded: CLR/Mono never uses it for managed exception |
1558 | 1570 | // translation. Chaining SIGABRT to a SIG_DFL previous handler calls |
@@ -1688,8 +1700,7 @@ process_ucontext(const sentry_ucontext_t *uctx) |
1688 | 1700 | sentry__atomic_store(&g_crash_handling_state, CRASH_STATE_DONE); |
1689 | 1701 |
|
1690 | 1702 | 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) { |
1693 | 1704 | invoke_signal_handler( |
1694 | 1705 | uctx->signum, uctx->siginfo, (void *)uctx->user_context); |
1695 | 1706 | } |
|
0 commit comments