php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45403 Script causes infinite loop
Submitted: 2008-07-01 14:42 UTC Modified: 2008-07-02 11:33 UTC
From: glaesser at whsoft dot de Assigned:
Status: Not a bug Package: Reproducible crash
PHP Version: 5.2CVS-2008-07-02 OS: Debian4, php 5.2.0-8+etch11
Private report: No CVE-ID: None
 [2008-07-01 14:42 UTC] glaesser at whsoft dot de
Description:
------------
Following script works perfect on PHP 5.0.5-Debian-0.8~sarge1 but it produces infinite loops on PHP 5.1.2 or PHP 5.2.0-8+etch11.

Reproduce code:
---------------
$testArray = array();
$testArray[] = array('ueberdat' => '2008-04-01', 'rueckdat' => '2008-04-06');
$testArray[] = array('ueberdat' => '2008-04-12', 'rueckdat' => '2008-04-26');
$testArray[] = array('ueberdat' => '2008-04-26', 'rueckdat' => '2008-05-03');
$testArray[] = array('ueberdat' => '2008-05-10', 'rueckdat' => '2008-05-20');
$testArray[] = array('ueberdat' => '2008-05-24', 'rueckdat' => '2008-06-07');
$testArray[] = array('ueberdat' => '2008-06-14', 'rueckdat' => '2008-06-21');
$testArray[] = array('ueberdat' => '2008-06-21', 'rueckdat' => '2008-06-28');
$testArray[] = array('ueberdat' => '2008-06-28', 'rueckdat' => '2008-07-05');
$testArray[] = array('ueberdat' => '2008-07-05', 'rueckdat' => '2008-07-12');
$testArray[] = array('ueberdat' => '2008-07-19', 'rueckdat' => '2008-07-26');
$testArray[] = array('ueberdat' => '2008-07-26', 'rueckdat' => '2008-08-02');
$testArray[] = array('ueberdat' => '2008-08-02', 'rueckdat' => '2008-08-16');
$testArray[] = array('ueberdat' => '2008-08-23', 'rueckdat' => '2008-09-06');
$testArray[] = array('ueberdat' => '2008-09-13', 'rueckdat' => '2008-09-20');
$testArray[] = array('ueberdat' => '2008-09-27', 'rueckdat' => '2008-10-04');
$testArray[] = array('ueberdat' => '2008-10-11', 'rueckdat' => '2008-10-15');
$testArray[] = array('ueberdat' => '2008-10-25', 'rueckdat' => '2008-11-02');

$arrRet = array();
foreach ($testArray as $testValue) {
	$startDat = $testValue['ueberdat'];
	while ($startDat < $testValue['rueckdat']) {
		$arrRet[] = array('belDat' => $startDat);
		$startDat = date("Y-m-d", strtotime($startDat)+86400);
	}
}

print_r($arrRet);

Expected result:
----------------
I want all days from the given dates like...

Array
(
    [0] => Array
        (
            [belDat] => 2008-04-01
        )

    [1] => Array
        (
            [belDat] => 2008-04-02
        )

    [2] => Array
        (
            [belDat] => 2008-04-03
        )

    [3] => Array
        (
            [belDat] => 2008-04-04
        )

    [4] => Array
        (
            [belDat] => 2008-04-05
        )

    [5] => Array
        (
            [belDat] => 2008-04-12
        )

    [6] => Array
        (
            [belDat] => 2008-04-13
        )

    [7] => Array
        (
            [belDat] => 2008-04-14
        )

    [8] => Array
        (
            [belDat] => 2008-04-15
        )

 ... and so on

Actual result:
--------------
Script timeout on new PHP-Version.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-07-02 10:10 UTC] glaesser at whsoft dot de
Tested on

Apache/2.2.8 (Win32) DAV/2 mod_ssl/2.2.8 OpenSSL/0.9.8g mod_autoindex_color PHP/5.2.7-dev configured -- resuming normal operations

Same problem:

Script timeout | Unable to allocate enough memory
 [2008-07-02 11:32 UTC] jani@php.net
It's actually just bad code. You're not considering that there's the DST change happening on 2008-10-26. (Last sunday on october in 2008).

 [2008-07-02 11:33 UTC] jani@php.net
And as you end up in endless loop filling an array will of course cause a crash. This is expected behaviour.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 14:01:31 2024 UTC