Bug #78521 [Opn->Csd]: request_terminate_timeout does not take effect in shutdown handlers
| From: | nikic@php.net | Date: | Mon, 30 Sep 2019 10:56:57 +0000 |
| Subject: | Bug #78521 [Opn->Csd]: request_terminate_timeout does not take effect in shutdown handlers | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-222959@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78521&edit=1
ID: 78521
Updated by: nikic@php.net
Reported by: turchanov at farpost dot com
Summary: request_terminate_timeout does not take effect in
shutdown handlers
-Status: Open
+Status: Closed
Type: Bug
Package: FPM related
Operating System: Linux
PHP Version: 7.3.9
-Assigned To:
+Assigned To: nikic
Block user comment: N
Private report: N
New Comment:
Fixed by linked PR:
Previous Comments:
------------------------------------------------------------------------
[2019-09-10 04:10:05] turchanov at farpost dot com
The following pull request has been associated:
Patch Name: Fix #78413: php-fpm request_terminate_timeout does not take effect afâ¦
On GitHub: https://github.com/php/php-src/pull/4637
Patch: https://github.com/php/php-src/pull/4637.patch
------------------------------------------------------------------------
[2019-09-10 04:07:10] turchanov at farpost dot com
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 this bug report at https://bugs.php.net/bug.php?id=78521&edit=1