|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78521 request_terminate_timeout does not take effect in shutdown handlers
Submitted: 2019-09-10 04:07 UTC Modified: 2019-09-30 10:56 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: turchanov at farpost dot com Assigned: nikic (profile)
Status: Closed Package: FPM related
PHP Version: 7.3.9 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: turchanov at farpost dot com
New email:
PHP Version: OS:


 [2019-09-10 04:07 UTC] turchanov at farpost dot com
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>
     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:

function func() {


Expected result:
Php worker being terminated by fpm after %request_terminate_timeout% of execution time


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-09-10 04:10 UTC] 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:
 [2019-09-30 10:56 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: nikic
 [2019-09-30 10:56 UTC]
Fixed by linked PR:
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Fri Dec 01 05:01:29 2023 UTC