php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48164 Script stops during a while
Submitted: 2009-05-06 13:01 UTC Modified: 2009-05-14 01:00 UTC
From: uvealonso at gmail dot com Assigned:
Status: No Feedback Package: Performance problem
PHP Version: 5.2.9 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
29 - 14 = ?
Subscribe to this entry?

 
 [2009-05-06 13:01 UTC] uvealonso at gmail dot com
Description:
------------
Sometimes, the script stops 10 secs after the start, and others, it doesn't stop and complete the operations...

I have tested with the same data and parameters, and sometimes, it stops 10 secs after the script starts.

max_execution_time is 500000

Reproduce code:
---------------
print "start";

while ($a){
    func_modify($a); //Here is a function that modifies $a
}

print "end";

Expected result:
----------------
start
end

Actual result:
--------------
sometimes:
"start"

or

"start
end"

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-06 13:36 UTC] fa@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.


I really think we need even a rough description what func_modify() does. From your description it could be a single complicated task or something with thousands of iterations
 [2009-05-06 19:49 UTC] uvealonso at gmail dot com
Ok, I give you this 2 codes:


First:
/////////////////////////////////////////////
$tiempo1=microtime(true);
print "START AT: ".$tiempo1."<br>";

//DO IT 15 SECONDS
while((microtime(true)-$tiempo1)<15){
	//PRINT EVERY STEP
	print "STEP: ".(microtime(true)-$tiempo1)."<br>";
}

//IT MUST END 15 SECS AFTER THE START
print "<br>END AT: ".(microtime(true)-$tiempo1);



Second:
//////////////////////////////////////////////////
$tm1=microtime(true);
print "START AT: ".$tm1."<br>";
$t=0;

//DO IT 15 SECONDS
while((microtime(true)-$tm1)<15){
	
	//PRINT STEPS OF 0.1 SECS
	if ((microtime(true)-$tm1)-$t>0.1){
		print "STEP: ".(microtime(true)-$tm)."<br>";
		$t=microtime(true)-$tm1;
	}
}

//IT MUST END 15 SECS AFTER THE START
print "<br>END AT: ".(microtime(true)-$tm1);




The 2 scripts must stop inmediately after 15 secs.
The first works fine, but 2? stops after 10 seconds...

You cant test it here:
First example: http://www.4mula1.es/libraries/pruebas/timeout-test-1.php
Second example: http://www.4mula1.es/libraries/pruebas/timeout-test-2.php



PS: They have exactly the same code that I have wrote in this comment.
 [2009-05-06 20:01 UTC] fa@php.net
Can't reproduce with 5.2.9 CLI, could you provide some more details about distribution, sapi, etc?
Or maybe test them on CLI?

(fa@debian):(~/code/src) $ time ./php-5.2.9/sapi/cli/php ~/tmp/while_48164-2.php > FOO2

real    0m15.011s
user    0m0.120s
sys     0m14.893s
(fa@debian):(~/code/src) $ time ./php-5.2.9/sapi/cli/php ~/tmp/while_48164.php > FOO

real    0m15.020s
user    0m0.160s
sys     0m14.749s

==> FOO <==
START AT: 1241598435.2784
==> FOO2 <==
START AT: 1241598254.2014

==> FOO <==
END AT: 15.000004053116
==> FOO2 <==
END AT: 15.000002145767
 [2009-05-06 20:07 UTC] uvealonso at gmail dot com
I can't change the PHP version because the hosting.

Get all the php info here:
http://www.4mula1.es/libraries/pruebas/phpinfo.php
 [2009-05-06 20:35 UTC] jani@php.net
I can not reproduce this either and your test scripts are inherently 
flawed anyway. Please provice proper reproducing scripts which start 
with <?php and end with ?> and don't have any notice/warning/fatal 
errors.
 [2009-05-14 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 14:01:31 2024 UTC