You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ZTS: pcntl signal handled by one PHP thread ends the process or is lost when delivered elsewhere #25549
Signal dispositions are process-wide, but under ZTS the PHP handler for a signal belongs to the thread that registered it. With several threads running PHP requests (an embedding application, for instance), a signal handled by one thread can end the process or be lost. GH-25542 fixes delivery to threads that never ran PHP, but these two cases remain.
1. A signal lands on a PHP thread that has no handler for it.
Thread A runs a request and calls pcntl_signal(SIGUSR1, $handler).
Thread B runs a request and has no handler for SIGUSR1.
SIGUSR1 is delivered to thread B.
2. Two threads handle the same signal and one finishes first.
Threads A and B each run a request and call pcntl_signal(SIGUSR1, $handler).
Thread B finishes its request.
SIGUSR1 is delivered to a thread that never ran PHP, while thread A is still running.
I reproduced both with a small embed SAPI program that runs each request on its own pthread and calls raise() on the target thread. Each result below is 10 of 10 runs, on a debug ZTS build:
Case
With zend signals
With --disable-zend-signals
1. PHP thread without a handler
Process terminated by SIGUSR1
Signal lost, A's handler never runs
2. Same signal, one thread finished
Process terminated by SIGUSR1
Process terminated by SIGUSR1
I expected thread A's handler to run in every case.
The results are the same with and without GH-25542. In case 2 without zend signals, thread B's RSHUTDOWN resets the signal to SIG_DFL for the whole process while thread A still relies on it.
This looks related to the discussion in GH-10193 about making the zend signal state process-wide rather than per thread.
Re-tested with the current version of GH-25542 (f582dba): both cases behave as described above.
One related detail for whoever looks at this: on macOS, sigprocmask() changes the signal mask of every thread in the process, which I confirmed with a small C program. pcntl_signal_dispatch() uses it, so while one thread dispatches, signals are blocked in the other threads as well.
Activity
phcorp commentedon Nov 18, 2026
Re-tested with the current version of GH-25542 (f582dba): both cases behave as described above.
One related detail for whoever looks at this: on macOS,
sigprocmask()changes the signal mask of every thread in the process, which I confirmed with a small C program.pcntl_signal_dispatch()uses it, so while one thread dispatches, signals are blocked in the other threads as well.Fix phpGH-25549: signals handled by another PHP thread
phcorp commentedon Nov 18, 2026
GH-25542 now includes a fix for this issue, with a regression test.