php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49868 max_execution_time affected by max_input_time
Submitted: 2009-10-13 17:41 UTC Modified: 2010-12-20 12:49 UTC
Votes:4
Avg. Score:4.5 ± 0.9
Reproduced:4 of 4 (100.0%)
Same Version:3 (75.0%)
Same OS:3 (75.0%)
From: majkl578 at gmail dot com Assigned: rasmus (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.3.1 OS: *
Private report: No CVE-ID: None
 [2009-10-13 17:41 UTC] majkl578 at gmail dot com
Description:
------------
PHP ignores the max_execution_time set in php.ini and sets (somehow internally) it to the value of max_input_time. ini_get returns correct values of both of these settings, but the script is halted after the time set as max_input_time.

This bug affects PHP5.3RC1 and also the latest snapshot of PHP5.3.
It is probably similar to an old bug #37306.

Related php.ini values:
max_execution_time = 5
max_input_time = 10

Configure command:
./configure --prefix=/usr --sysconfdir=/etc --cache-file=./config.cache --with-config-file-path=/etc/php --with-config-file-scan-dir=/etc/php/extensions --with-apxs2=/usr/bin/apxs2 --with-mysql --with-mysqli --with-curl --with-sqlite --enable-sqlite-utf8 --with-gd --enable-mbstring --with-openssl --disable-short-tags --with-mcrypt --with-bz2 --with-zlib --enable-zip --with-xmlrpc --enable-soap --without-mssql --with-pgsql --with-tidy --enable-debug --disable-posix --enable-exif --enable-ftp --with-gettext --with-mhash --enable-pcntl --with-pspell --enable-sockets --with-xsl --enable-cli --enable-calendar --disable-cgi --enable-zend-multibyte

Reproduce code:
---------------
<?php
echo ini_get('max_execution_time'), ' | ', ini_get('max_input_time');

while(true);

Expected result:
----------------
5 | 10
Fatal error: Maximum execution time of 5 seconds exceeded in /foo/bar.php on line 4

Actual result:
--------------
5 | 10
Fatal error: Maximum execution time of 10 seconds exceeded in /foo/bar.php on line 4

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-10-13 18:02 UTC] Sjoerd@php.net
See also bug #37306 max_execution_time = max_input_time
 [2009-10-14 11:31 UTC] majkl578 at gmail dot com
This problem does not appear neither on PHP 5.2.6 (windows binary) nor 5.2.10 (gentoo pkg).
 [2009-11-12 23:36 UTC] majkl578 at gmail dot com
still present in 5.3.1RC4
 [2009-11-13 10:02 UTC] jani@php.net
Rasmus, this patch of yours broke it:

http://svn.php.net/viewvc?view=revision&revision=255405

And in that, changes to main.c file, last one:

-  zend_set_timeout(INI_INT("max_execution_time"));
+  zend_set_timeout(EG(timeout_seconds), 0);

This is done inside php_execute_script(). A bit confusing part is that this happens only when PG(max_input_time) != -1 and there's no comments in the code why it is so. :)
 [2009-11-14 22:48 UTC] rasmus@php.net
The idea behind the code is that during request startup before we hit the zend_execute_scripts() call, the timeout is set to max_input_time if it is defined.  max_input_time will be -1 if it has not been defined.  Then just before zend_execute_scripts() we have:

   if (PG(max_input_time) != -1) {
#ifdef PHP_WIN32
      zend_unset_timeout(TSRMLS_C);
#endif
      zend_set_timeout(INI_INT("max_execution_time"));
   }

So when script execution starts we are using the max_execution_time value.

I'll have to follow the logic through a bit more closely.  I must have missed something somewhere, but that is the idea behind the code.
 [2009-11-15 00:21 UTC] svn@php.net
Automatic comment from SVN on behalf of rasmus
Revision: http://svn.php.net/viewvc/?view=revision&revision=290766
Log: Fix bug #49868
As far as I can tell this was a copy-paste induced bug when I added
the reset_signals flag to zend_set_timeout.
 [2009-11-15 00:24 UTC] svn@php.net
Automatic comment from SVN on behalf of rasmus
Revision: http://svn.php.net/viewvc/?view=revision&revision=290767
Log: Fix bug #49868
 [2009-11-15 00:24 UTC] rasmus@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2010-12-20 12:49 UTC] jani@php.net
-Package: Tidy +Package: Scripting Engine problem
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 30 18:01:27 2024 UTC