From: sqchen at citiz dot net
Operating system: redhat 7.3
PHP version: 5.1.2
PHP Bug Type: Streams related
Bug description: memory leaks in stream problems
Description:
------------
It seems that stream function can cause memory leaks so easily. We hope
the stream developer fix it as soon as possible.
Here is another one: it leaks when you add ./configure --enable-debug
Reproduce code:
---------------
<?php
class upper_filter extends php_user_filter{
function filter($in, $out, &$consumed, $closing) {
while($bucket=stream_bucket_make_writeable($in)){
$fp=fopen("2.txt", "w");
$bucket=stream_bucket_new($fp, "Abc\n");
$bucket->data = strtoupper($bucket->data);
$consumed += $bucket->datalen;
stream_bucket_append($out, $bucket);
}
return PSFS_PASS_ON;
}
}
stream_filter_register("upper", "upper_filter");
$fp=fopen("2.txt", "w");
stream_filter_append($fp, "upper");
fread($fp, 1024);
fwrite($fp, "Thank you\n");
fclose($fp);
readfile("2.txt");
unlink("2.txt");
?>
Actual result:
--------------
[EMAIL PROTECTED] sqchen]$ $php tt.php
ABC
~
[Tue Mar 28 16:54:43 2006] Script: 'tt.php'
/home/sqchen/sqchen/php-5.1.2/main/streams/filter.c(129) : Freeing
0x083EE864 (10 bytes), script=tt.php
[Tue Mar 28 16:54:43 2006] Script: 'tt.php'
/home/sqchen/sqchen/php-5.1.2/main/streams/filter.c(126) : Freeing
0x083EE814 (32 bytes), script=tt.php
=== Total 2 memory leaks detected ===
--
Edit bug report at http://bugs.php.net/?id=36886&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=36886&r=trysnapshot44
Try a CVS snapshot (PHP 5.1):
http://bugs.php.net/fix.php?id=36886&r=trysnapshot51
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=36886&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=36886&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=36886&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=36886&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=36886&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=36886&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=36886&r=support
Expected behavior: http://bugs.php.net/fix.php?id=36886&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=36886&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=36886&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=36886&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36886&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=36886&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=36886&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=36886&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=36886&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=36886&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=36886&r=mysqlcfg