php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31721 Wrong memory object management
Submitted: 2005-01-27 13:10 UTC Modified: 2005-02-09 01:00 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: marek dot raida at oskar dot cz Assigned:
Status: No Feedback Package: Class/Object related
PHP Version: 5.0.3 OS: FreeBSD, Solaris, maybe more...
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
43 - 15 = ?
Subscribe to this entry?

 
 [2005-01-27 13:10 UTC] marek dot raida at oskar dot cz
Description:
------------
When references between more objects, and on of objects is extended from domDocument, has reference to it caller object and use its property in vsprinf, reference to orignal object is destroyed or wrongly managed by garbageCollector... Really confusing -> could be workarounded by calling method of domDocument extended object from outside of referenced object...


Reproduce code:
---------------
<?php
class a {
  public $a = array(1,2,3);
  function aa($b){ $b->bb(); }
}
class b extends domDocument {
  public $a = NULL;
  function bb(){ $x = vsprintf('www %s www %s www %s www', $this->a->a) ; }
}
class x {
  public $a = null; public $b = null;
  function __construct() {
    $this->a = new a(); $this->b = new b();
    $this->b->a = $this->a;
    var_dump('Object a',$this->a, 'Object b',$this->b);
    $this->a->aa($this->b);
    var_dump('Object a',$this->a, 'Object b',$this->b);
  }
}
$x = new x();
?>

Expected result:
----------------
string(8) "Object a"
object(a)#2 (1) {
  ["a"]=>
  array(3) {
    [0]=>
    int(1)
    [1]=>
    int(2)
    [2]=>
    int(3)
  }
}
string(8) "Object b"
object(b)#3 (1) {
  ["a"]=>
  object(a)#2 (1) {
    ["a"]=>
    array(3) {
      [0]=>
      int(1)
      [1]=>
      int(2)
      [2]=>
      int(3)
    }
  }
}
string(8) "Object a"    <<< RIGHT
object(a)#2 (1) {
  ["a"]=>
  array(3) {
    [0]=>
    int(1)
    [1]=>
    int(2)
    [2]=>
    int(3)
  }
}
string(8) "Object b"
object(b)#3 (1) {
  ["a"]=>
  object(a)#2 (1) {
    ["a"]=>
    array(3) {
      [0]=>
      int(1)
      [1]=>
      int(2)
      [2]=>
      int(3)
    }
  }
}


Actual result:
--------------
string(8) "Object a"
object(a)#2 (1) {
  ["a"]=>
  array(3) {
    [0]=>
    int(1)
    [1]=>
    int(2)
    [2]=>
    int(3)
  }
}
string(8) "Object b"
object(b)#3 (1) {
  ["a"]=>
  object(a)#2 (1) {
    ["a"]=>
    array(3) {
      [0]=>
      int(1)
      [1]=>
      int(2)
      [2]=>
      int(3)
    }
  }
}
string(8) "Object a"
string(8) "Object a"  <<<  WRONG
string(8) "Object b"
object(b)#3 (1) {
  ["a"]=>
  string(8) "Object a"
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-27 13:14 UTC] marek dot raida at oskar dot cz
I forgot to mention that in PHP 5.0.2 everything works correctly...
 [2005-02-01 11:21 UTC] rrichards@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.0-win32-latest.zip

I believe this was a dom problem whiich was already fixed in CVS
 [2005-02-09 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 19:01:29 2024 UTC