|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2014-07-12 09:27 UTC] hylent at qq dot com
Description:
------------
On thread-safe debug build, in a try-catch code block, when constructing a multidimensional array, in case that some value in the array throws exceptions, there will be memory leaks!
Test script:
---------------
<?php
class Foo {
public static function bar() {
throw new Exception();
}
}
try {
$a = array(
'a' => 'aa',
'b' => array(
'c' => Foo::bar(),
),
);
} catch (Exception $e) {
echo $e, PHP_EOL;
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 01:00:01 2026 UTC |
Output: vagrant@vagrant-ubuntu-trusty-64:~/php-src/5.4$ ./sapi/cli/php /tmp/test.php exception 'Exception' in /tmp/test.php:4 Stack trace: #0 /tmp/test.php(11): Foo::bar() #1 {main} [Mon Jul 14 16:35:32 2014] Script: '/tmp/test.php' /home/vagrant/php-src/5.4/Zend/zend_vm_execute.h(3674) : Freeing 0x7FFCC0430CA0 (32 bytes), script=/tmp/test.php [Mon Jul 14 16:35:32 2014] Script: '/tmp/test.php' /home/vagrant/php-src/5.4/Zend/zend_vm_execute.h(3737) : Freeing 0x7FFCC0433C60 (72 bytes), script=/tmp/test.php /home/vagrant/php-src/5.4/Zend/zend_API.c(982) : Actual location (location was relayed) [Mon Jul 14 16:35:33 2014] Script: '/tmp/test.php' /home/vagrant/php-src/5.4/Zend/zend_hash.c(292) : Freeing 0x7FFCC0433D08 (64 bytes), script=/tmp/test.php /home/vagrant/php-src/5.4/Zend/zend_alloc.c(2539) : Actual location (location was relayed) [Mon Jul 14 16:35:33 2014] Script: '/tmp/test.php' /home/vagrant/php-src/5.4/Zend/zend_vm_execute.h(3677) : Freeing 0x7FFCC0434110 (3 bytes), script=/tmp/test.php /home/vagrant/php-src/5.4/Zend/zend_variables.c(123) : Actual location (location was relayed) [Mon Jul 14 16:35:33 2014] Script: '/tmp/test.php' /home/vagrant/php-src/5.4/Zend/zend_hash.c(330) : Freeing 0x7FFCC04342B0 (74 bytes), script=/tmp/test.php === Total 5 memory leaks detected ===