|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78919 CLI server does insufficient cleanup if php_request_startup() fails
Submitted: 2019-12-06 14:42 UTC Modified: 2021-07-30 13:39 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: Assigned: cmb (profile)
Status: Closed Package: Built-in web server
PHP Version: 7.2.25 OS: Irrelevant
Private report: No CVE-ID: None
 [2019-12-06 14:42 UTC]
If php_request_startup() fails, for instance because an extension throws an error during its RINIT, then the CLI server doesn't run php_request_shutdown().

In particular, the memory manager will not be shutdown, which means that repeatedly issuing errors during RINIT will result in eventually PHP running out of memory.

Test script:

build the image and start a container. Then hit http://localhost:8080/ After 3 or requests, the CLI server will exit due to lack of memory.

Expected result:
The server runs continuously.

Actual result:
The server exits after a couple of requests.


cli_no_exit.diff (last revision 2019-12-06 14:43 UTC by contratempo at gmail dot com)

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2019-12-06 14:43 UTC] contratempo at gmail dot com
The following patch has been added/updated:

Patch Name: cli_no_exit.diff
Revision:   1575643429
 [2019-12-07 13:10 UTC]
Thanks!  I wonder, though, whether it is generally safe to call
`php_request_shutdown()` after `php_request_startup()` has failed.
 [2019-12-07 14:10 UTC]
The Apache SAPI does call shutdown after a failed startup:

and we haven't had any crashes reported from the errors raised during RINIT in our extension (sqreen).

FPM simply exists if there's an error during RINIT but it can be worked around easily for our purposes.
 [2021-07-30 13:38 UTC]
The following pull request has been associated:

Patch Name: Fix #78919: CLI server: insufficient cleanup if request startup fails
On GitHub:
 [2021-07-30 13:39 UTC]
-Assigned To: +Assigned To: cmb
 [2021-08-17 10:41 UTC]
Automatic comment on behalf of cmb69
Log: Fix #78919: CLI server: insufficient cleanup if request startup fails
 [2021-08-17 10:41 UTC]
-Status: Assigned +Status: Closed
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue May 21 11:01:34 2024 UTC