ZTS with --disable-zend-signals: execution timeout delivered to a non-PHP thread is lost and kills the process
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 48/100
Rechercherichtung
Start by reading zend_timeout_handler() and the signal forwarding path used by pcntl_signal_handler() for ZTS builds with --disable-zend-signals; the issue does not name source files or tests. Reproduce on the described macOS arm64 setup using the provided script and the zend_test_raise_on_foreign_thread() helper from GH-25542. Done means the timeout produces the expected PHP fatal error instead of losing the signal and terminating the process with SIGALRM.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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)
- Vorherrschende Sprache
- C
- Sterne
- 41.8k
- Forks
- 8.6k
- Ø Merge
- 2 T. 15 Std.
- Gemergte PRs (30 T.)
- 125
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus php/php-src
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
ext/openssl: 8.2.31+/8.3.31+ fail to build against OpenSSL 1.0.2 (ASN1_STRING_get0_data in xp_ssl.c)OffenExtension: openssl Status: Needs Triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 79/100
php/php-src#25402 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Bug Status: Needs Triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
php/php-src#25397 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
SNMP accepts malformed remote portsEvtl. vergeben @somethingwithproof hat das vor 21 Tagen übernommen. Offen
Schwierigkeit 2/5 Ein halber Tag Anfängerfreundlichkeit 62/100
php/php-src#25137 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Bug Status: Needs Triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
Maintainer antworten meist innerhalb von 1 Tag
-
ZIP/ZIPS decode dereferences NULL when the cached libdeflate decompressor can't be allocated (3.5 regression)Evtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
AcademySoftwareFoundation/openexr#2884 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
python-pillow/Pillow#10590 ·
Maintainer antworten meist innerhalb von 1 Tag
-
status: needs-triage type: bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
openwrt/packages#31407 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag