Skip to content

Commit ef5b4f1

Browse files
jpnurmiclaude
andcommitted
Clarify why raw syscall is needed to bypass libsigchain
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b20d459 commit ef5b4f1

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

src/backends/sentry_backend_inproc.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,8 +1572,19 @@ process_ucontext(const sentry_ucontext_t *uctx)
15721572
sigset_t mask, old_mask;
15731573
sigemptyset(&mask);
15741574
sigaddset(&mask, uctx->signum);
1575-
// Raw syscall to bypass libsigchain, whose sigprocmask guard
1576-
// is only active inside its own special handlers.
1575+
// Raw syscall because ART's libsigchain intercepts
1576+
// sigprocmask() and silently drops the request when called
1577+
// outside its own special handlers. Without the raw syscall
1578+
// the mask change would be ignored and SA_NODEFER would let
1579+
// the chained handler's raise() re-deliver the signal
1580+
// immediately, crashing the process before we can inspect
1581+
// the modified IP/SP.
1582+
//
1583+
// DANGER: this makes libsigchain's internal mask state
1584+
// diverge from the kernel's actual mask. If ART ever relies
1585+
// on that state for correctness (e.g. GC safepoints), this
1586+
// could cause subtle failures. We restore the mask right
1587+
// after the chained handler returns, limiting the window.
15771588
syscall(
15781589
SYS_rt_sigprocmask, SIG_BLOCK, &mask, &old_mask, sizeof(sigset_t));
15791590
# endif

0 commit comments

Comments
 (0)