#45047 [NEW]: memory leak with array as default function parameter in encoded code
| From: | lars_teuber at gmx dot de | Date: | Tue, 20 May 2008 08:38:50 +0000 |
| Subject: | #45047 [NEW]: memory leak with array as default function parameter in encoded code | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-125137@lists.php.net to get a copy of this message | ||
From: lars_teuber at gmx dot de
Operating system: linux
PHP version: 5.2.6
PHP Bug Type: Reproducible crash
Bug description: memory leak with array as default function parameter in encoded code
Description:
------------
memory leak with array as default function parameter in encoded code
- code encoded by Zend Guard 5.0.1
- tested on linux, apache with php 5.2.5 and php 5.2.6
- not reproducible under Windows (IIS, php 5.2.6 or Apache, php 5.2.5)
- not reproducible with unencoded code
- memory leak occurs only under linux with Zend encoded code
Reproduce code:
---------------
<?php
$max = 1000000;
// this leaks if the code is encoded
$start_mem = memory_get_usage(true);
for ($i = 0; $i < $max; $i++) {
leak();
}
echo 'leak mem1: [' . (memory_get_usage(true) - $start_mem) . "]\n<br>";
// this does not leak
$start_mem = memory_get_usage(true);
for ($i = 0; $i < $max; $i++) {
leak(array($i));
}
echo 'leak mem2: [' . (memory_get_usage(true) - $start_mem) . ']';
function leak($leak = array()) {}
?>
Expected result:
----------------
leak mem1: [0]
leak mem2: [0]
Actual result:
--------------
leak mem1: [87818240]
leak mem2: [0]
--
Edit bug report at http://bugs.php.net/?id=45047&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45047&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45047&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45047&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=45047&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=45047&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=45047&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=45047&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=45047&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=45047&r=support
Expected behavior: http://bugs.php.net/fix.php?id=45047&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=45047&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=45047&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=45047&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45047&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=45047&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=45047&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=45047&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=45047&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=45047&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=45047&r=mysqlcfg