From: cunha17 at uol dot com dot br
Operating system: RedHat Linux 9.0
PHP version: 5CVS-2003-08-31 (dev)
PHP Bug Type: Zend Engine 2 problem
Bug description: Memory Leak with error handler and exceptions

Description:
------------
This code below gives some memory leak. The leak only appears when
throwing exceptions inside error handler.
The code I'm using is a little more complex 'cause it translates PHP
errors into PHP Exceptions, but this piece of code reproduces the leak
correctly.


Reproduce code:
---------------
<?
function my_error($nr, $text, $file, $line, $vars)
{
throw new Exception($text);
}

error_reporting(E_ALL);
set_error_handler("my_error");

try {
include("unexistent");
} catch (Exception $e) {
echo "EXCEPTION!!!";
}
?>

Expected result:
----------------
EXCEPTION!!!

Actual result:
--------------
EXCEPTION!!!/usr/src/zend2/php-src/Zend/zend.c(914) : Freeing 0x404C9340
(16 bytes), script=leak.php
=== Total 1 memory leaks detected ===


--
Edit bug report at [url]http://bugs.php.net/?id=25335&edit=1[/url]
--
Try a CVS snapshot (php4): [url]http://bugs.php.net/fix.php?id=25335&r=trysnapshot4[/url]
Try a CVS snapshot (php5): [url]http://bugs.php.net/fix.php?id=25335&r=trysnapshot5[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=25335&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=25335&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=25335&r=needtrace[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=25335&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=25335&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=25335&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=25335&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=25335&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=25335&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=25335&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=25335&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=25335&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=25335&r=gnused[/url]