php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24746 Fatal error: Nesting level too deep - recursive dependency?
Submitted: 2003-07-21 19:56 UTC Modified: 2003-07-21 21:14 UTC
From: tim at sparkart dot com Assigned:
Status: Not a bug Package: Reproducible crash
PHP Version: 4.3.3RC1 OS: Linux/FreeBSD
Private report: No CVE-ID: None
 [2003-07-21 19:56 UTC] tim at sparkart dot com
Description:
------------
The code (attached) produces the following error: Fatal error: Nesting level too deep - recursive dependency? in /home/tim/www/crash2.php on line 15

I started getting this bug with some code we are running and did some google searches and found something on the php-dev list (where the sample code is from) from 9/22/02: http://www.geocrawler.com/archives/3/5/2002/9/50/9731982/

This happens on our Linux and FreeBSD boxes running PHP 4.3.2, 4.3.1, and I just installed the latest CVS version (php4-STABLE-200307212330) and got the same error.  For the CVS version I configured using "./configure" and ran it through the command line on a Red Hat 8 box.

I saw other mentions of this error floating around but couldn't find anything recent so sorry if this is a repeat.

Reproduce code:
---------------
<?php
    class A {
        var $b;
         function A() { $this->b =& new B($this); }
    }    
     
    class B {
        var $a;
        function B(&$a) { $this->a =& $a; }
    }    
     
    $one =& new A;
    $two =& $one; 
    
    if ($one == $two) {  // <-- fatal error here
        echo "Same object\n";
    } else {
        echo "not the same object\n";
    }
?> 

Expected result:
----------------
Expected it to not give a fatal error.


Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-21 20:41 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Your object looks like this:
object(a)#1 (1) {
  ["b"]=>
  object(b)#2 (1) {
    ["a"]=>
    &object(a)#1 (1) {
      ["b"]=>
      object(b)#2 (1) {
        ["a"]=>
        *RECURSION*
      }
    }
  }
}
Which should explain the error message you are seeing.
 [2003-07-21 21:14 UTC] tim at sparkart dot com
Under Comparing objects in PHP 4 (http://www.php.net/manual/en/language.oop.object-comparison-php4.php) it says:

"In PHP 4, objects are compared in a very simple manner, namely: Two object instances are equal if they have the same attributes and values, and are instances of the same class."

So wouldn't the expected result of "Same Object" match this description?
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Aug 16 02:01:29 2024 UTC