#46380 [NEW]: incorrect reference counting in "=&new".
| From: | marek dot miska at netart dot pl | Date: | Fri, 24 Oct 2008 13:40:24 +0000 |
| Subject: | #46380 [NEW]: incorrect reference counting in "=&new". | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-130043@lists.php.net to get a copy of this message | ||
From: marek dot miska at netart dot pl
Operating system: linux
PHP version: 5.2.6
PHP Bug Type: Reproducible crash
Bug description: incorrect reference counting in "=&new".
Description:
------------
Incorrect reference counting in:
ZEND_VM_HANDLER(39, ZEND_ASSIGN_REF, VAR|CV, VAR|CV)
refcount is decremented twice.
(In short: ZEND_RETURNS_FUNCTION for "new" is missing).
It's fixed in 5.3.0alpha1 with ZEND_RETURNS_NEW.
But it will be nice to have it also in stable version.
Reproduce code:
---------------
<?
class A{
function A() {
global $g;
$g[0] = $g[1] = $this;
}
function __destruct() { }
}
$g = array();
for($i=0; $i<1000; ++$i)
{
$a =& new A;
}
?>
Expected result:
----------------
Exit without any errors.
Actual result:
--------------
Segmentation fault
--
Edit bug report at http://bugs.php.net/?id=46380&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=46380&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=46380&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=46380&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=46380&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=46380&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=46380&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=46380&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=46380&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=46380&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=46380&r=support
Expected behavior: http://bugs.php.net/fix.php?id=46380&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=46380&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=46380&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=46380&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=46380&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=46380&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=46380&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=46380&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=46380&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=46380&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=46380&r=mysqlcfg