Bug #62210 [Asn]: Exceptions can leak temporary variables
| From: | dmitry@php.net | Date: | Mon, 25 Jun 2012 08:12:36 +0000 |
| Subject: | Bug #62210 [Asn]: Exceptions can leak temporary variables | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-171507@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=62210&edit=1
ID: 62210
Updated by: dmitry@php.net
Reported by: nikic@php.net
Summary: Exceptions can leak temporary variables
Status: Assigned
Type: Bug
Package: Scripting Engine problem
PHP Version: Irrelevant
Assigned To: dmitry
Block user comment: N
Private report: N
New Comment:
I confirm the bug, but I don't see a simple way to fix it.
In general, it's possible to extend zend_op_array with information about ranges of temporary
variables livenes, but overhead is going to be too high.
Previous Comments:
------------------------------------------------------------------------
[2012-06-02 00:46:39] nikic@php.net
Description:
------------
The script
<?php
function throwException() { throw new Exception }
function doSomething() { [] + throwException(); }
try { doSomething(); } catch (Exception $e) { }
leaks
/home/nikic/dev/php-src/Zend/zend_vm_execute.h(25625) : Freeing 0xB77ABA44 (44 bytes), script=-
/home/nikic/dev/php-src/Zend/zend_API.c(982) : Actual location (location was relayed)
=== Total 1 memory leaks detected ===
This generally always happens whenever an exception is thrown while evaluation an expression which
contains (non-scalar) temporary variables. In the above case the array hash table is leaked.
The reason is that the FREE opcode for the temporary variable is never executed due to the
exception. Exceptions only free temporary loop variables.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=62210&edit=1