#29423 [Asn->Csd]: reference count gets wrong when return-reference-calling a normal function

From: Date: Tue, 07 Jun 2005 09:58:33 +0000
Subject: #29423 [Asn->Csd]: reference count gets wrong when return-reference-calling a normal function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-79995@lists.php.net to get a copy of this message
 ID:               29423
 Updated by:       derick@php.net
 Reported By:      stefan at hotpaenz dot de
-Status:           Assigned
+Status:           Closed
 Bug Type:         Scripting Engine problem
 Operating System: Linux 2.6.3
 PHP Version:      5CVS, 4CVS
 Assigned To:      dmitry
 New Comment:

This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.




Previous Comments:
------------------------------------------------------------------------

[2005-03-07 12:49:06] derick@php.net

Confirmed here too (with PHP 4) and it leaks too:

string(16) "This is a string"
/dat/dev/php/php-5.0dev/Zend/zend_execute.c(253) :  Freeing 0x085E7994
(16 bytes), script=-
=== Total 1 memory leaks detected ===


assigning to Dmitry

------------------------------------------------------------------------

[2005-03-07 12:13:42] stefan at hotpaenz dot de

Of course you could make this code cause an fatal error 
(instead of the "expected result" that PHP4 returns), but 
please please please don't let it fail silently. It easily 
leads to errors that are really hard to track.

------------------------------------------------------------------------

[2005-03-07 11:50:47] stefan at hotpaenz dot de

The bug remains for me with "latest cvs" snapshot 
200503070930, configured with 
 
./configure --disable-cli --enable-cgi --without-pear 
--disable-all

------------------------------------------------------------------------

[2005-03-06 22:12:14] sniper@php.net

Please try using this CVS snapshot:

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



------------------------------------------------------------------------

[2004-07-28 10:59:58] stefan at hotpaenz dot de

Description:
------------
See the code below: 
 
An object of ClassA is passed to FuncB, which calls FuncA 
with the return-by-reference operator. FuncA is not 
designed to return by reference. 
 
The reference count seems to get wrong by doing that so 
the object is discarded when FuncB returns. 
 

Reproduce code:
---------------
<?php
class ClassA { }

function FuncA($obj) {
    return $obj;
}

function FuncB($obj) {
    $dummy = &FuncA($obj);
}

$obj = new ClassA();
FuncB($obj);
$str='This is a string'
var_dump($obj);


Expected result:
----------------
object(ClassA)#1 (0) { } 
 

Actual result:
--------------
string(16) "This is a string" 
 


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=29423&edit=1


Thread (7 messages)

« previous php.bugs (#79995) next »