#36886 [Opn->Csd]: memory leaks in stream problems
| From: | iliaa@php.net | Date: | Tue, 28 Mar 2006 16:01:13 +0000 |
| Subject: | #36886 [Opn->Csd]: memory leaks in stream problems | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-95022@lists.php.net to get a copy of this message | ||
ID: 36886
Updated by: iliaa@php.net
Reported By: sqchen at citiz dot net
-Status: Open
+Status: Closed
Bug Type: Streams related
Operating System: redhat 7.3
PHP Version: 5.1.2
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2006-03-28 11:01:37] sqchen at citiz dot net
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:
--------------
[sqchen@localhost 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 this bug report at http://bugs.php.net/?id=36886&edit=1