From: bertrand at toggg dot com
Operating system: Linux 2.6.11-1 glibc 2.3.5-0
PHP version: 4CVS-2005-07-02 (stable)
PHP Bug Type: Scripting Engine problem
Bug description: double free or corruption by 65537 elements in array
Description:
------------
This script simply augments an array by duplicating its first element a
parameter number of time, then displays count of the array and memory
usage.
$ php finout.php 65536
count:65536/2968016 bytes
$ php finout.php 65537
count:65537/3230200 bytes
*** glibc detected *** double free or corruption (!prev): 0x0923ce30 ***
Aborted
When count reaches 65537 glibc issues this "post-mortem" message
If instead of $arr[] = $arr[0]; I use $arr[] = 'x'; this message does not
come.
Reproduce code:
---------------
<?php
$loop = isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1]+0 : 1000;
error_reporting(E_ALL);
$arr = array ('x') ;
while (--$loop) {
$arr[] = $arr[0];
}
echo 'count:'.count($arr).'/'.memory_get_usage() . " bytes\n";
?>
--
Edit bug report at http://bugs.php.net/?id=33551&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33551&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=33551&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=33551&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33551&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33551&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33551&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33551&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33551&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33551&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33551&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=33551&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=33551&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33551&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33551&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33551&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33551&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33551&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33551&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33551&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33551&r=mysqlcfg