From: [EMAIL PROTECTED]
Operating system: Linux
PHP version: 5CVS-2007-04-13 (CVS)
PHP Bug Type: Scripting Engine problem
Bug description: memleak when creating default object caused exception
Description:
------------
Kinda hard to explain, better look at the code below.
The leak is only reproducible when return value is used, remove $var and
it's gone.
Reproduce code:
---------------
<?php
function err($errno, $errstr, $errfile, $errline)
{
throw new Exception($errstr);
}
set_error_handler("err");
class test {
function foo() {
$var = $this->blah->prop = "string";
var_dump($this->blah);
}
}
$t = new test;
try {
$t->foo();
} catch (Exception $e) {
var_dump($e->getMessage());
}
?>
Actual result:
--------------
==11422== 7 bytes in 1 blocks are indirectly lost in loss record 1 of 2
==11422== at 0x401C6CE: malloc (vg_replace_malloc.c:149)
==11422== by 0x82BEA9F: _emalloc (zend_alloc.c:2231)
==11422== by 0x82BED45: _estrndup (zend_alloc.c:2353)
==11422== by 0x82D75CF: _zval_copy_ctor_func (zend_variables.c:120)
==11422== by 0x833BDD4: _zval_copy_ctor (zend_variables.h:45)
==11422== by 0x833D047: zend_assign_to_object (zend_execute.c:593)
==11422== by 0x830DA7A: ZEND_ASSIGN_OBJ_SPEC_VAR_CONST_HANDLER
(zend_vm_execute.h:9226)
==11422== by 0x82F8680: execute (zend_vm_execute.h:92)
==11422== by 0x82F8BA2: zend_do_fcall_common_helper_SPEC
(zend_vm_execute.h:234)
==11422== by 0x82F8FB9: ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER
(zend_vm_execute.h:322)
==11422== by 0x82F8680: execute (zend_vm_execute.h:92)
==11422== by 0x82D92F7: zend_execute_scripts (zend.c:1134)
==11422== by 0x828FE7C: php_execute_script (main.c:1790)
==11422== by 0x833FA35: main (php_cli.c:1127)
==11422==
==11422==
==11422== 23 (16 direct, 7 indirect) bytes in 1 blocks are definitely lost
in loss record 2 of 2
==11422== at 0x401C6CE: malloc (vg_replace_malloc.c:149)
==11422== by 0x82BEA9F: _emalloc (zend_alloc.c:2231)
==11422== by 0x833CFFF: zend_assign_to_object (zend_execute.c:589)
==11422== by 0x830DA7A: ZEND_ASSIGN_OBJ_SPEC_VAR_CONST_HANDLER
(zend_vm_execute.h:9226)
==11422== by 0x82F8680: execute (zend_vm_execute.h:92)
==11422== by 0x82F8BA2: zend_do_fcall_common_helper_SPEC
(zend_vm_execute.h:234)
==11422== by 0x82F8FB9: ZEND_DO_FCALL_BY_NAME_SPEC_HANDLER
(zend_vm_execute.h:322)
==11422== by 0x82F8680: execute (zend_vm_execute.h:92)
==11422== by 0x82D92F7: zend_execute_scripts (zend.c:1134)
==11422== by 0x828FE7C: php_execute_script (main.c:1790)
==11422== by 0x833FA35: main (php_cli.c:1127)
--
Edit bug report at http://bugs.php.net/?id=41075&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=41075&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=41075&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=41075&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41075&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=41075&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=41075&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=41075&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=41075&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=41075&r=support
Expected behavior: http://bugs.php.net/fix.php?id=41075&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=41075&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=41075&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41075&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41075&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41075&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=41075&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=41075&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=41075&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=41075&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=41075&r=mysqlcfg