php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17498 still infinite loop in print_r
Submitted: 2002-05-28 20:35 UTC Modified: 2002-10-19 17:05 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: mikx at mikx dot de Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.2.1 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mikx at mikx dot de
New email:
PHP Version: OS:

 

 [2002-05-28 20:35 UTC] mikx at mikx dot de
There is a note in the documentation that since PHP 4.0.4 infinite loop situations like print_r($GLOBALS) are handled and get stopped. But there are still situations print_r() results in an infinite loop:

foreach($GLOBALS as $i) 
{ 
print_r($GLOBALS); 
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-29 13:07 UTC] yohgaki@php.net
You don't have to report the same bug report.
We know it, it's just nobody care to fix it.


 [2002-10-19 17:05 UTC] iliaa@php.net
This bug has been fixed in CVS.

In case this was a PHP problem, 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/.
 
In case this was a documentation problem, the fix will show up soon at
http://www.php.net/manual/.

In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites in short time.
 
Thank you for the report, and for helping us make PHP better.


 [2003-03-01 17:49 UTC] qwerty at ut dot ee
in RedHat php-4.2.2 i have noticed thisproblem (is it fixed in some newer version of PHP?):

======PHP CODE STARTS=========
<?php

class test {
        var $nr = 0;
        var $sub1 = null;

        function test() {
                $this->sub1 =& new sub(&$this);
                $this->nr++;
        }
}

class sub {
        var $parent = null;

        function sub($pObj) {
                $this->parent = &$pObj;
        }
}


$mytest =& new test();

print_r($mytest);
?>

======PHP CODE ENDS=========

and outout is following:

test Object
(
    [nr] => 1
    [sub1] => sub Object
        (
            [parent] => test Object
                (
                    [nr] => 1
                    [sub1] =>  *RECURSION*
                )

        )

)

but the problem is: the *RECURSION* must allready be in [parent] because the [parent] is a pointer/reference to parent object...

am i right or wrong ?

in more complicated solutions where are more objects that use  references to their parents, print_r()  can not handle the recursion well and results in an infinite loop...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 18 03:02:51 2024 UTC