From:             lee dot sargeant dot ls at wbpdata dot com
Operating system: Windows 2000 Server SP4
PHP version:      5.1.4
PHP Bug Type:     Reproducible crash
Bug description:  Function Loop, CPU 100%

Description:
------------
6 dates should be outputted when the function in the script is executed.
Instead I get a CPU 100% Usage and a fatal error once hitting 60 seconds.
I have tried increasing the Memory to allow for a script but it did not
work. Also tried on another clean server running a fresh install of PHP
5.1.4

Reproduce code:
---------------
function scheduleWorkingDay($daysback, $day, $month, $year) 
{

//$arr = db_arr("SELECT * FROM issue_days WHERE title_id = $titleid");

$datetotime = strtotime($year.'-'.$month.'-'.$day);

$counter = 1;
$thiscount = 1;

while ( $counter != $daysback ) {

$suffix = $thiscount;
$goback         = strtotime("-$suffix days", $datetotime);
$dateformat = date("d-m-y",$goback);
$day = date("D",$goback);


if ( $day == "Sat" ) { 
$thiscount++;
//next;

} elseif ( $day == "Sun" ) { 
$thiscount++; 
//next;

} else {
                //print "Got Workday [$day $counter]\n";
                $thiscount++ ;
                $counter++ ;
                //next;
} }
echo $dateformat;

}

Expected result:
----------------
As the function is called in a loop that runs 6 times, 6 dates outputted
from the above code.

Actual result:
--------------
PHP causes the server CPU to hit 100% and wille eventually timeout with a
fatal error. If the loop runs for less than 6 times, the output is exactly
as expected.

-- 
Edit bug report at http://bugs.php.net/?id=37789&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=37789&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=37789&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=37789&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=37789&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=37789&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=37789&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=37789&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=37789&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=37789&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=37789&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=37789&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=37789&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=37789&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=37789&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=37789&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=37789&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=37789&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=37789&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=37789&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=37789&r=mysqlcfg

Reply via email to