php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37375 foreach memory leaks when work with try-catch
Submitted: 2006-05-09 06:08 UTC Modified: 2006-05-10 10:11 UTC
From: chen dot daqi at gmail dot com Assigned:
Status: Not a bug Package: Unknown/Other Function
PHP Version: 6CVS-2006-05-09 (CVS) OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: chen dot daqi at gmail dot com
New email:
PHP Version: OS:

 

 [2006-05-09 06:08 UTC] chen dot daqi at gmail dot com
Description:
------------
When a exception is throwed from a foreach, memory leak will happen

Reproduce code:
---------------
<?php
try{
$ar = array(1, 2, 3);
foreach($ar as $ele)
        {
                throw new Exception("new exception");
        }
}
catch(Exception $e)
{
        echo $e->getMessage()."\n";
}
?>


Expected result:
----------------
new exception


Actual result:
--------------
new exception
[Tue May  9 13:40:13 2006]  Script:  'test.php'
/home/xlchen/php-5.1.2/Zend/zend_execute.c(843) :  Freeing 0x0847FD5C (16 bytes)                                                                             , script=test.php
[Tue May  9 13:40:13 2006]  Script:  'test.php'
/home/xlchen/php-5.1.2/Zend/zend_vm_execute.h(3370) :  Freeing 0x0847FCAC (35 by                                                                             tes), script=test.php
/home/xlchen/php-5.1.2/Zend/zend_hash.c(383) : Actual location (location was rel                                                                             ayed)
Last leak repeated 2 times
[Tue May  9 13:40:13 2006]  Script:  'test.php'
/home/xlchen/php-5.1.2/Zend/zend_vm_execute.h(3339) :  Freeing 0x0846D054 (16 by                                                                             tes), script=test.php
Last leak repeated 2 times
[Tue May  9 13:40:13 2006]  Script:  'test.php'
/home/xlchen/php-5.1.2/Zend/zend_vm_execute.h(3320) :  Freeing 0x084809AC (32 by                                                                             tes), script=test.php
/home/xlchen/php-5.1.2/Zend/zend_hash.c(169) : Actual location (location was rel                                                                             ayed)
Last leak repeated 1 time
=== Total 9 memory leaks detected ===


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-10 10:11 UTC] tony2001@php.net
Duplicate of bug #34065.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Nov 30 10:00:01 2025 UTC