php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32264 refcount is not updated
Submitted: 2005-03-10 16:27 UTC Modified: 2005-03-15 17:04 UTC
From: tangi dot maury at wanadoo dot fr Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 4.3.9 OS: windows 2000
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: tangi dot maury at wanadoo dot fr
New email:
PHP Version: OS:

 

 [2005-03-10 16:27 UTC] tangi dot maury at wanadoo dot fr
Description:
------------
I'd like use '=null' on variables who points to object.
but the refcount is not updated in this case.
It is updated only after unset on variable.

is it a real pb ?

By,

Reproduce code:
---------------
a small test ->

  class a{ 
  }

  class b extends a{   
  }

  class t{
    var $r = null;
    var $pr = null;
    function test(){
      $this->r = &new b();
      echo "nb Ref r apres new = " . pars_infoo($this->r);
      $this->pr = &$this->r;
      echo "<br/>nb Ref pr apres pr = " . pars_infoo($this->r);
      echo "<br/>nb Ref r apres pr = " . pars_infoo($this->pr);
      //unset($this->pr); OK
      $this->pr = null;
      echo "<br/>   nb Ref r apres unset " . pars_infoo($this->r);
    }
  }

  $b= new t();
  $b->test();


source for pars_infoo(Zend)
if ((*pO)->is_ref)
  ret = strUWFormat(ret, nPos, &nPos, "nb r?f?rence = %hd", (*pO)->refcount);



Expected result:
----------------
if i make unset it's ok
->
nb Ref r apres unset nb r?f?rence = 2 <- ok


Actual result:
--------------
->

nb Ref r apres new = nb r?f?rence = 2
nb Ref pr apres pr = nb r?f?rence = 3
nb Ref r apres pr = nb r?f?rence = 3
nb Ref r apres unset nb r?f?rence = 3 <- wrong



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-03-14 01:14 UTC] sniper@php.net
Fatal error: Call to undefined function:  pars_infoo()...

What's that pars_infoo() function supposed to be?
And please use ENGLISH in your test script. (I don't understand french)


 [2005-03-14 08:49 UTC] tangi dot maury at wanadoo dot fr
I write it in Zend Language and compile with vc++ 6.

static const unsigned char arg_ref[]    = {1, BYREF_FORCE};

PHP_FE(pars_infoo, (unsigned char *) arg_ref)

PHP_FUNCTION(pars_infoo){
  pval ** pO = NULL;
  char ret[50];
  ret[0] = 0;
  if (zend_get_parameters_ex(1, &pO) == FAILURE) return;
  if ((*pO)->is_ref)
    sprintf(ret, "ref count = %hd", (*pO)->refcount);
  RETVAL_STRING(ret, 1);
  return;
}
 [2005-03-14 21:49 UTC] sniper@php.net
Try replacing "pars_infoo" with "debug_zval_dump" as it will give reliable results.

 [2005-03-15 17:04 UTC] tangi dot maury at wanadoo dot fr
Whith debug_zval_dump
  i have the result 1 ->
object(b)(0) refcount(1){ }

  It's alays the same refcount, even i refer the object 
  more than once. 

  I think it's a wrong test.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 22:01:33 2024 UTC