From:             thecanadiancrappler at hotmail dot com
Operating system: Windows XP SP 1
PHP version:      4.3.8
PHP Bug Type:     Reproducible crash
Bug description:  Memory leak when looping an associative array

Description:
------------
When looping numerically through an associative array, certain operations
cause a massive memory leak in Apache, eating up all available ram at
about 60mb/s.  Windows grinds to a halt as 1gb of Virtual Memory is
gobbled up.  

Trying to echo each element of the array returns nothing as would be
expected, but concatting or executing a function such a stripslashes on
the elements causes the memory leak.

My php.ini differs only in max_execution time and the maximum size of POST
uploads.

Reproduce code:
---------------
$array['a'] = 'Some text';
$array['b'] = "It\'s nice text";

 // prints 2
echo count($array);

 // prints nothing
echo $array[0];

 // does nothing
$array[0] = stripslashes($array[0]);


for ($i=0; $i<count($array); $i++)
{
         // does nothing
        echo $array[$i];

         // memory leak
        $array[$i] = 'blah' . $array[$i];

         // memory leak
        $array[$i] = stripslashes($array[$i]);
}

Expected result:
----------------
To have no effect on the array

Actual result:
--------------
Sorry, I can't decipher your instructions for using backtrace!  Shoot the
stupid guy ;o)

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

Reply via email to