php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77524 max_execution_time=0, max_input_time>0 in cycle - Fatal error: execution time
Submitted: 2019-01-26 01:25 UTC Modified: -
Votes:6
Avg. Score:3.8 ± 0.9
Reproduced:4 of 4 (100.0%)
Same Version:0 (0.0%)
Same OS:2 (50.0%)
From: roman-ak at wmkeeper dot com Assigned:
Status: Open Package: *General Issues
PHP Version: 7.3.1 OS: Debian 4.9.30-2+deb9u5 x86_64
Private report: No CVE-ID: None
 [2019-01-26 01:25 UTC] roman-ak at wmkeeper dot com
Description:
------------
At
PHP 7.0.33-1 + 0 ~ 20181208203126.8 + stretch ~ 1.gbp2ff763 and
PHP 7.3.1-1 + 0 ~ 20190113101756.25 + stretch ~ 1.gbp15aaa9,
if max_execution_time = 0 and max_input_time > 0, then at the start of any cycle, the max_input_time limit starts to be spent, that is, in fact, max_execution_time becomes equal to max_input_time. For example, a loop: while (true) {}. In the documentation about this nothing is said. As a result, when the max_input_time limit expires, a fatal error occurs: Fatal error: Maximum execution time of 0 seconds exceeded in /var/www/html/....php on line ... The content of message is incorrect, since 0 seconds is the removal of any restriction and cannot expire and the expiration should be max_input_time, not the "execution time".

My solution to the problem is:
This problem disappears if max_input_time = 0, but disabling the max_input_time limit will critically violate the security of the server, as it will allow multi big long upload attacks. Therefore, in the config and in general, you should leave the standard max_input_time = 60.
If the cycle, whatever it was and whatever it was in, may take more than a certain time in max_input_time, then to solve the problem:
before the loop, add: $max_execution_time = ini_get('max_execution_time'); //fix php bug - Fatal error in loop - part 1/3
Add to the end of the loop: set_time_limit(ini_get('max_input_time')); //fix php bug - Fatal error in loop - part 2/3
after the cycle add: set_time_limit($max_execution_time); //fix php bug - Fatal error in loop - part 3/3
These actions need to be performed only for long cycles exceeding the standard minute, for the remaining cycles nothing needs to be done.

Same old issues:
https://bugs.php.net/bug.php?id=37306
https://bugs.php.net/bug.php?id=42706
https://bugs.php.net/bug.php?id=49868

Please, or fix bug, or add information in documentation.

Test script:
---------------
in php.ini:
max_execution_time = 0
max_input_time = 60

script:
while (true) {}

Expected result:
----------------
infinity loop

Actual result:
--------------
After 60 second: "Maximum execution time of 0 seconds exceeded in /var/www/html/....php on line ..."

Patches

Pull Requests

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 09 13:01:26 2024 UTC