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
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: 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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 30 01:01:28 2024 UTC