php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79003 Cannot use `exit` in preloading script
Submitted: 2019-12-19 21:05 UTC Modified: 2020-08-10 11:03 UTC
Votes:3
Avg. Score:3.7 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:0 (0.0%)
From: webdevxp dot com at gmail dot com Assigned:
Status: Verified Package: opcache
PHP Version: 7.4.1 OS:
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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: webdevxp dot com at gmail dot com
New email:
PHP Version: OS:

 

 [2019-12-19 21:05 UTC] webdevxp dot com at gmail dot com
Description:
------------
When use `exit` to do clean exit (without argument or with 0 or with string), PHP-FPM will exit with code 70.

Test script:
---------------
<?php
exit;


Expected result:
----------------
PHP-FPM continues normally.

Actual result:
--------------
PHP-FPM exits with code 70.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-12-20 12:03 UTC] drtechno at mail dot com
There is a couple of things to look at to debug code 70 (resources expended before exit) 

looking at a version's install:
pm = dynamic
pm.max_children = 5
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 4
pm.max_requests = 200


pm.max_requests should be 500 to 800, not 200 


If you have a decent amount of memory, try pm = static. As the memory management of dynamic mode is not that great, and I think its still a little too new and buggy.

even though it should be set this way, in the config file:

daemonize = no

Also, it doesn't hurt to pass the switch on the command argument. Some say they have to because if they don't sometimes its starts in deamon mode. The argument to pass with the command:
--nodaemonize

Just remember, this module eats ram like crazy. Especially on non ascii (and greater than 7bit) character sets.  

Its not a really good idea to run it as a daemon because its very power hungry nature, but if you do I recommend a machine with no less than 16 core, with 256GB of ram.
 [2019-12-20 12:43 UTC] bugreports at gmail dot com
drtechno what are you talking about?

you can't do exit() in 'opcache.preload' script, no matter the environment, it's that easy, period

on the other hand you shouldn't need too, the preload script can be easily written in a way that everything is wrapped in if/switch statements and is executed or not dpending on the environment
 [2019-12-30 11:46 UTC] nikic@php.net
-Status: Open +Status: Verified
 [2019-12-30 11:46 UTC] nikic@php.net
Can confirm that exit causes preloading to fail.

This is likely a "won't fix" for PHP 7.4. "exit" is essentially equivalent to generating a fatal error and may leave the engine in an inconsistent state. There are plans to make exit use stack unwinding in PHP 8, in which case we can also allow its use during preloading.
 [2020-08-10 11:03 UTC] nikic@php.net
In PHP 8 we now have the technical capability of handling exit() gracefully. It's not obvious to me though that an "exit" in the preload script should just get ignored. That doesn't seem in line with how it is treated usually.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC