Skip to content

Commit a804de3

Browse files
jpnurmiclaude
andcommitted
fix: gate raw syscalls to Android, use sigprocmask elsewhere
libsigchain's sigprocmask guard is only active inside its own special handlers, so our signal handler still gets filtered. Keep the raw syscall on Android and use the standard sigprocmask on other platforms. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 986a153 commit a804de3

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/backends/sentry_backend_inproc.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,12 +1565,17 @@ process_ucontext(const sentry_ucontext_t *uctx)
15651565
uintptr_t sp = get_stack_pointer(uctx);
15661566

15671567
// Mask the signal so SA_NODEFER doesn't let re-raises from the chained
1568-
// handler to kill the process before we regain control.
1568+
// handler kill the process before we regain control.
15691569
sigset_t mask, old_mask;
15701570
sigemptyset(&mask);
15711571
sigaddset(&mask, uctx->signum);
1572-
// raw syscall to bypass libsigchain on Android
1572+
# ifdef SENTRY_PLATFORM_ANDROID
1573+
// Raw syscall to bypass libsigchain, whose sigprocmask guard
1574+
// is only active inside its own special handlers.
15731575
syscall(SYS_rt_sigprocmask, SIG_BLOCK, &mask, &old_mask, _NSIG / 8);
1576+
# else
1577+
sigprocmask(SIG_BLOCK, &mask, &old_mask);
1578+
# endif
15741579

15751580
// invoke the previous handler (typically the CLR/Mono
15761581
// signal-to-managed-exception handler)
@@ -1599,7 +1604,11 @@ process_ucontext(const sentry_ucontext_t *uctx)
15991604
syscall(SYS_rt_sigtimedwait, &mask, NULL, &timeout, _NSIG / 8);
16001605

16011606
// unmask
1607+
# ifdef SENTRY_PLATFORM_ANDROID
16021608
syscall(SYS_rt_sigprocmask, SIG_SETMASK, &old_mask, NULL, _NSIG / 8);
1609+
# else
1610+
sigprocmask(SIG_SETMASK, &old_mask, NULL);
1611+
# endif
16031612

16041613
// return from runtime handler; continue processing the crash on the
16051614
// signal thread until the worker takes over

0 commit comments

Comments
 (0)