|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-05-13 14:55 UTC] nikic@php.net
Description:
------------
Attached script causes a leak:
caught b
[Fri May 13 16:51:34 2016] Script: '/home/nikic/php-src/t275.php'
/home/nikic/php-src/Zend/zend_objects.c(174) : Freeing 0x7F6FB46740C0 (152 bytes), script=/home/nikic/php-src/t275.php
=== Total 1 memory leaks detected ===
The leak is the exception backed up in the outer fast_call, which needs to be discarded.
Test script:
---------------
<?php
function test() {
try {
throw new Exception('a');
} finally {
try {
throw new Exception('b');
} finally {
}
}
}
try {
test();
} catch (Exception $e) {
echo "caught {$e->getMessage()}\n";
}
Patchesbug72213.diff (last revision 2016-05-16 15:37 UTC by laruence@php.net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 06:00:01 2025 UTC |
This patch does not look correct to me... First, it breaks this code: <?php function test() { try { throw new Exception(1); } finally { try { try { throw new Exception(2); } finally {} } catch (Exception $e) {} } } try { test(); } catch (Exception $e) { echo "caught {$e->getMessage()}\n"; } Previously this correctly threw Exception(1), matching Java. Now nothing is thrown instead. Second, it only avoids the leak for one nesting level. This will still leak: <?php function test() { try { throw new Exception('a'); } finally { try { } finally { try { throw new Exception('b'); } finally { } } } } try { test(); } catch (Exception $e) { echo "caught {$e->getMessage()}\n"; }