Skip to content

ZTS with --disable-zend-signals: execution timeout delivered to a non-PHP thread is lost and kills the process #25548

Open

Description

@phcorp

Description

On a ZTS build configured with --disable-zend-signals, the execution timeout signal can be delivered to a thread that never ran PHP, such as a libdispatch worker on macOS. zend_timeout_handler() then prints a message and returns without setting EG(timed_out), so the timeout is lost. The handler is installed with SA_RESETHAND, so the signal's disposition is back to SIG_DFL and the next one terminates the process.

The script below needs zend_test_raise_on_foreign_thread(), which GH-25542 adds to zend_test. It raises the signal on a new thread, which makes the delivery deterministic.

<?php
set_time_limit(1);
zend_test_raise_on_foreign_thread(SIGALRM);
$end = hrtime(true) + 3_000_000_000;
while (hrtime(true) < $end);
echo "no timeout\n";

Resulted in this output (5 of 5 runs, process terminated by SIGALRM):

zend_timeout_handler() called in a thread not managed by PHP. The expected signal handler will not be called. This is probably a bug.

But I expected this output instead:

Fatal error: Maximum execution time of 1 second exceeded in %s on line %d

With zend signals enabled, GH-25542 forwards the signal to the PHP thread and the script produces the expected fatal error. Without zend signals, only pcntl_signal_handler() forwards. zend_timeout_handler() does not, so this configuration is not covered.

SIGALRM is the timeout signal on macOS arm64. I have only tested this platform.

PHP Version

PHP-8.4 branch (8.4.29-dev), debug ZTS build with --disable-zend-signals, with GH-25542 applied for the test helper

Operating System

macOS (arm64)

Activity

  1. added a commit that references this issue on Nov 18, 2026
    5928bcc
  2. phcorp commented on Nov 18, 2026

    @phcorp
    Author

    GH-25542 now includes a fix for this issue, with a regression test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions