php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67610 Memory leak on zts debug build
Submitted: 2014-07-12 09:27 UTC Modified: 2016-03-27 20:16 UTC
Votes:4
Avg. Score:2.2 ± 0.8
Reproduced:0 of 0 (0.0%)
From: hylent at qq dot com Assigned: nikic (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.4.30 OS: centos
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: hylent at qq dot com
New email:
PHP Version: OS:

 

 [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;
}



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-07-14 16:36 UTC] aharvey@php.net
-Status: Open +Status: Verified
 [2014-07-14 16:36 UTC] aharvey@php.net
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 ===
 [2016-03-27 20:16 UTC] nikic@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: nikic
 [2016-03-27 20:16 UTC] nikic@php.net
This has been fixed in PHP 7.1. The fix will not be ported to older versions as it involves complex compiler changes.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 01:00:01 2026 UTC