From: [EMAIL PROTECTED]
Operating system: Linux
PHP version: 5CVS-2007-04-17 (CVS)
PHP Bug Type: Scripting Engine problem
Bug description: another complex memleak
Description:
------------
The code below causes two small memleaks.
Reproduce code:
---------------
<?php
function err($errno, $errstr, $errfile, $errline) {
throw new Exception($errstr);
}
set_error_handler("err");
function foo() {
$a = array("aaa");
foreach ($a as $o) {
//$this->prop[$a] = foo($undef2); //no leak
//$this->prop["aa"] = foo($undef2); //no leak
$this->prop[$a[0]] = foo($undef2); //leak
}
}
try {
foo();
} catch (Exception $e) {
var_dump($e->getMessage());
}
?>
Actual result:
--------------
==10584== 4 bytes in 1 blocks are indirectly lost in loss record 1 of 2
==10584== at 0x401C6CE: malloc (vg_replace_malloc.c:149)
==10584== by 0x82995DF: _emalloc (zend_alloc.c:2231)
==10584== by 0x8299885: _estrndup (zend_alloc.c:2353)
==10584== by 0x82B210F: _zval_copy_ctor_func (zend_variables.c:120)
==10584== by 0x831694C: _zval_copy_ctor (zend_variables.h:45)
==10584== by 0x82D9FAB:
ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_UNUSED_HANDLER (zend_vm_execute.h:3562)
==10584== by 0x82DA140: ZEND_INIT_ARRAY_SPEC_CONST_UNUSED_HANDLER
(zend_vm_execute.h:3609)
==10584== by 0x82D31F8: execute (zend_vm_execute.h:92)
==10584== by 0x82D371A: zend_do_fcall_common_helper_SPEC
(zend_vm_execute.h:234)
==10584== by 0x82D6614: ZEND_DO_FCALL_SPEC_CONST_HANDLER
(zend_vm_execute.h:1681)
==10584== by 0x82D31F8: execute (zend_vm_execute.h:92)
==10584== by 0x82B3E37: zend_execute_scripts (zend.c:1134)
==10584== by 0x826A9BC: php_execute_script (main.c:1790)
==10584== by 0x831A5B5: main (php_cli.c:1127)
==10584==
==10584==
==10584== 20 (16 direct, 4 indirect) bytes in 1 blocks are definitely lost
in loss record 2 of 2
==10584== at 0x401C6CE: malloc (vg_replace_malloc.c:149)
==10584== by 0x82995DF: _emalloc (zend_alloc.c:2231)
==10584== by 0x82D9F5D:
ZEND_ADD_ARRAY_ELEMENT_SPEC_CONST_UNUSED_HANDLER (zend_vm_execute.h:3559)
==10584== by 0x82DA140: ZEND_INIT_ARRAY_SPEC_CONST_UNUSED_HANDLER
(zend_vm_execute.h:3609)
==10584== by 0x82D31F8: execute (zend_vm_execute.h:92)
==10584== by 0x82D371A: zend_do_fcall_common_helper_SPEC
(zend_vm_execute.h:234)
==10584== by 0x82D6614: ZEND_DO_FCALL_SPEC_CONST_HANDLER
(zend_vm_execute.h:1681)
==10584== by 0x82D31F8: execute (zend_vm_execute.h:92)
==10584== by 0x82B3E37: zend_execute_scripts (zend.c:1134)
==10584== by 0x826A9BC: php_execute_script (main.c:1790)
==10584== by 0x831A5B5: main (php_cli.c:1127)
--
Edit bug report at http://bugs.php.net/?id=41113&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=41113&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=41113&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=41113&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41113&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=41113&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=41113&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=41113&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=41113&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=41113&r=support
Expected behavior: http://bugs.php.net/fix.php?id=41113&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=41113&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=41113&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41113&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41113&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41113&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=41113&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=41113&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=41113&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=41113&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=41113&r=mysqlcfg