Bug #78521 [NEW]: request_terminate_timeout does not take effect in shutdown handlers

From: Date: Tue, 10 Sep 2019 04:07:10 +0000
Subject: Bug #78521 [NEW]: request_terminate_timeout does not take effect in shutdown handlers
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222674@lists.php.net to get a copy of this message
From: turchanov at farpost dot com Operating system: Linux PHP version: 7.3.9 Package: FPM related Bug Type: Bug Bug description:request_terminate_timeout does not take effect in shutdown handlers Description: ------------ PHP shutdown handlers (registered via register_shutdown_function) are not tracked for request_terminate_timeout. This bug is related to bug #78413 due to the same underlying reasons. Request processing loop in fpm_main.c does this sequence of calls: while () { <get request> ... php_execute_script() ... fpm_request_end() -> sets request stage to FPM_REQUEST_FINISHED ... php_request_shutdown() --> calls shutdown handlers } and since request_termination_timeout is applied only to ((stage > FPM_REQUEST_ACCEPTING) && (stage < FPM_REQUEST_END)) it is effectively ignored. This creates an opportunity for PHP code to seize control of worker process for an arbitrary amount of time. Test script: --------------- <?php function func() { sleep(100000); } register_shutdown_function('func'); Expected result: ---------------- Php worker being terminated by fpm after %request_terminate_timeout% of execution time -- Edit bug report at https://bugs.php.net/bug.php?id=78521&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=78521&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=78521&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=78521&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=78521&r=needscript Try newer version: https://bugs.php.net/fix.php?id=78521&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=78521&r=support Expected behavior: https://bugs.php.net/fix.php?id=78521&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=78521&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=78521&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=78521&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=78521&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=78521&r=dst IIS Stability: https://bugs.php.net/fix.php?id=78521&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=78521&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=78521&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=78521&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=78521&r=mysqlcfg

« previous php.bugs (#222674) next »