php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6039 PHP Crashed if class contain reference by other class
Submitted: 2000-08-09 01:31 UTC Modified: 2000-08-15 06:57 UTC
From: rezinkin at mail dot ru Assigned:
Status: Closed Package: Reproducible Crash
PHP Version: 4.0.1pl2 OS: Windows95 OSR2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: rezinkin at mail dot ru
New email:
PHP Version: OS:

 

 [2000-08-09 01:31 UTC] rezinkin at mail dot ru
+++ crashed script:

<?
class B {

   var $pA;

   function B()
   {
   }

   function Show_m_A()
   {
      echo $this->pA->Show_m_A();
   }
}

class A {   
   
   var $m_A;
   var $B;

   function A($a)
   {
      $this->m_A = $a;
      $this->B = new B();
      $this->B->pA = &$this;
   }

   function Show_m_A()
   {
      echo "A->m_A = ".$this->m_A.'<BR>';
   }

   function Show_B_m_A()
   {
      echo $this->B->Show_m_A();
   }
}


$a = new A(1);

$a->Show_m_A();
echo "<HR>";
$a->Show_B_m_A();
echo "<HR>";
$a->m_A = 2;
$a->Show_m_A();
echo "<HR>";
$a->Show_B_m_A();
echo "<HR>";
?>

+++ php.ini - default
+++ Additionlal modules : none

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-09 23:14 UTC] waldschrott@php.net
verified...
Crashes too on W2K. But *after* the script has finished...

Does *not* crash me on Linux.
 [2000-08-13 04:27 UTC] stas@php.net
I see circular reference here. PHP doesn't do circular references.
 [2000-08-13 07:17 UTC] waldschrott@php.net
what exactly creates that crash here, following the exact
way PHP should go through the code I cannot reveal any
paradox or complicated situations...
 [2000-08-14 09:24 UTC] waldschrott@php.net
if Rasmus hadn?t mentioned that duplicates will be deleted,
I?d mark this a duplicate (it dups 5620, references leak
mem), Andi said it should leak but not crash, thus reopening
 [2000-08-14 09:44 UTC] waldschrott@php.net
Here is a "light" version crashing my W2K system.
I?ve also attached (in my eyes) equivalent non-crashing code.


Crash code:

<?php
class a { }
class b {
function b(&$obj) {
$this->a=&$obj;
$this->a->b=&$this; }}


$a=new a;
$b=new b($a);
?>
//var_dump($b);

Equivalent non-crash code:

<?php
class a { }
class b {}

$a=new a;
$b=new b;
$a->b=&$b;
$a->b->a=&$a;
//var_dump($a);
?>

 [2000-08-14 09:49 UTC] waldschrott@php.net
there?s ony & too many:

- $this->a=&$obj;
+ $this->a=$obj;

but crashes anyway
 [2000-08-15 06:57 UTC] stas@php.net
Should be fixed in CVS, please check.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 15 05:01:33 2025 UTC