Skip to content

fix: re-apply SA_ONSTACK to every extension signal handler - #2746

Merged
dunglas merged 1 commit into
php:mainfrom
mstegmeyer:fix/sa-onstack-all-signals
Oct 23, 2026
Merged

dunglas merged 1 commit into
php:mainfrom
mstegmeyer:fix/sa-onstack-all-signals

Conversation

@mstegmeyer

Copy link
Copy Markdown
Contributor

Closes #2745

frankenphp_startup() already adds SA_ONSTACK to handlers that extensions install during MINIT, but only for SIGSEGV, SIGBUS and SIGFPE (#2650). An asynchronous signal handler without the flag is just as unsafe on a Go thread. Its signal frame overflows the goroutine stack into the neighbouring one, and the runtime crashes later in GC. dd-trace-php's SIGVTALRM handler does exactly this in production (DataDog/dd-trace-php#4354).

This applies the existing fix-up to every signal. The test extension now installs a SIGVTALRM handler next to the SIGSEGV one. Go's own handlers already carry the flag, so only extension handlers change. Handlers installed after startup, such as pcntl_signal(), are still not covered, as before.

The extended internal/testext test fails on main and passes with the change. go test -race ./... passes against PHP 8.5.12 ZTS (linux/arm64).

@mstegmeyer
mstegmeyer force-pushed the fix/sa-onstack-all-signals branch from a472acb to 0dfc1c5 Compare October 22, 2026 06:14
@dunglas
dunglas merged commit 1838a2d into php:main Oct 23, 2026
26 checks passed
@mstegmeyer
mstegmeyer deleted the fix/sa-onstack-all-signals branch October 23, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Re-apply SA_ONSTACK to every extension signal handler, not only SIGSEGV/SIGBUS/SIGFPE

3 participants