Bug #79003 [Ver]: Cannot use `exit` in preloading script

From: Date: Mon, 10 Aug 2020 11:03:51 +0000
Subject: Bug #79003 [Ver]: Cannot use `exit` in preloading script
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-228487@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79003&edit=1 ID: 79003 Updated by: nikic@php.net Reported by: webdevxp dot com at gmail dot com Summary: Cannot use exit in preloading script Status: Verified Type: Bug Package: opcache PHP Version: 7.4.1 Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [2019-12-30 11:46:55] 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. ------------------------------------------------------------------------ [2019-12-20 12:43:01] 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-20 12:03:07] 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-19 21:05:07] 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. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=79003&edit=1

« previous php.bugs (#228487) next »