From: xris at siliconmechanics dot com Operating system: redhat 7.3, 8 and 9 PHP version: Irrelevant PHP Bug Type: Reproducible crash Bug description: recursive data structures issue
Description: ------------ Can't upgrade, production environment. Happens on 4.2.2 and earlier, and I'm forced to assume that it's still happening on more modern versions. Ran into this problem with a much more complicated piece of code. Basically, I have an array nested in an object. The array contains other objects that then reference the parent object ala circular linked-list. The provided example uses print_r to create an overflow, though my actual code the overflow happens elsewhere (I can't figure out where in my code the overflow is being generated, since I never actually traversed the list, as print_r does). I know that it's the same problem because both print_r and my code stabilize the instant I remove the recursive entry from the second object (luckily for me, it wasn't needed). Reproduce code: --------------- class a { var $items = array(); function a() { } } class b { var $a; function b(&$a) { $this->a = &$a; } } $a = new a(); $a->items[] = new b($a); $a->items[] = new b($a); $a->items[] = new b($a); # this much is ok $a->items[] = new b($a); # the proverbial straw print_r($a); Expected result: ---------------- get a printout from print_r where all recursive entries are marked: a Object ( [items] => Array ( [0] => b Object (# [a] => *RECURSION* ) [1] => b Object ( [a] => *RECURSION* ) ) ) Actual result: -------------- With fewer items, the recursion is not properly detected, leading to an overflow as more items are added. With too many items in the array, nothing. php dies, or something like that. IE produces a "page not found" error, and gecko just redisplays whatever page was previously loaded, with no error returned (I expected a "document contains no data" error, but never got it). -- Edit bug report at http://bugs.php.net/?id=24811&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=24811&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=24811&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=24811&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=24811&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=24811&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=24811&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=24811&r=support Expected behavior: http://bugs.php.net/fix.php?id=24811&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=24811&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=24811&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=24811&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=24811&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=24811&r=dst IIS Stability: http://bugs.php.net/fix.php?id=24811&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=24811&r=gnused