Bug #80728 [NEW]: PHP built-in web server resets timeout when it can kill the process
| From: | calvin at cmpct dot info | Date: | Wed, 10 Feb 2021 17:34:42 +0000 |
| Subject: | Bug #80728 [NEW]: PHP built-in web server resets timeout when it can kill the process | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-232041@lists.php.net to get a copy of this message | ||
From: calvin at cmpct dot info
Operating system: Fedora 33
PHP version: 7.4.15
Package: Built-in web server
Bug Type: Bug
Bug description:PHP built-in web server resets timeout when it can kill the process
Description:
------------
When the PHP built-in development webserver finishes a request, it
resets PHP's timer to defaults. On ITIMER_PROF (most) platforms, this
usually isn't a problem because listening causes PHP to block on listen,
stopping it from counting in execution time. On ITIMER_REAL platforms
(IBM i and Cygwin), the timer will continue to count down and hit the
hard timeout, killing an idle PHP development web server. (This may
affect other mediums of PHP, but the development web server is the
easiest case.)
The attached patch will add debug output for handling the ITIMER cases
and let you force ITIMER_REAL on Linux.
The issue is likely reproducible on 7.3 and 8.0.
Test script:
---------------
<?php
set_time_limit(10); // recommend setting to a large value to diagnose
ITIMER_REAL
$i = 0;
while(true) {
sleep(1); // comment if using ITIMER_PROF because it won't
count
echo "$i<br/>\n";
$i++;
ob_flush();
flush();
}
Expected result:
----------------
$ (cd ~/src/long/; /tmp/php7.4/bin/php -S 0.0.0.0:8080; date)
[Wed Feb 10 13:19:30 2021] PHP 7.4.15RC1 Development Server
(http://0.0.0.0:8080) started
[Wed Feb 10 13:19:30 2021] 127.0.0.1:45308 Accepted
** Setting prof timer for 30.0 seconds **
** UnSetting prof timer **
** Setting prof timer for 10.0 seconds **
** Setting prof timer for 2.0 seconds **
[Wed Feb 10 13:19:41 2021] 127.0.0.1:45308 [200]: GET / - Maximum
execution time of 10 seconds exceeded in /home/calvin/src/long/index.php
on line 11
** UnSetting prof timer **
** UnSetting prof timer **
** Setting prof timer for 30.0 seconds **
[Wed Feb 10 13:19:41 2021] 127.0.0.1:45308 Closing
Actual result:
--------------
$ (cd ~/src/long/; /tmp/php7.4/bin/php -S 0.0.0.0:8080; date)
[Wed Feb 10 13:13:34 2021] PHP 7.4.15RC1 Development Server
(http://0.0.0.0:8080) started
[Wed Feb 10 13:13:38 2021] 127.0.0.1:45126 Accepted
** Setting real timer for 30.0 seconds **
** UnSetting real timer **
** Setting real timer for 10.0 seconds **
** Setting real timer for 2.0 seconds **
[Wed Feb 10 13:13:48 2021] 127.0.0.1:45126 [200]: GET / - Maximum
execution time of 10 seconds exceeded in /home/calvin/src/long/index.php
on line 8
** UnSetting real timer **
** UnSetting real timer **
** Setting real timer for 30.0 seconds **
[Wed Feb 10 13:13:48 2021] 127.0.0.1:45126 Closing
[Wed Feb 10 13:13:48 2021] 127.0.0.1:45128 Accepted
[Wed Feb 10 13:13:48 2021] 127.0.0.1:45128 Closed without sending a
request; it was probably just an unused speculative preconnection
[Wed Feb 10 13:13:48 2021] 127.0.0.1:45128 Closing
** Setting real timer for 2.0 seconds ** Fatal error: Maximum execution
time of 30+2 seconds exceeded (terminated) in Unknown on line 0
Wed 10 Feb 2021 01:14:20 PM AST
--
Edit bug report at https://bugs.php.net/bug.php?id=80728&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=80728&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=80728&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=80728&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=80728&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=80728&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=80728&r=support
Expected behavior: https://bugs.php.net/fix.php?id=80728&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=80728&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=80728&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=80728&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80728&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=80728&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=80728&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=80728&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=80728&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=80728&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=80728&r=mysqlcfg