Bug #79235 [Opn->Dup]: Large consumption of memory when using a user filter
| From: | nikic@php.net | Date: | Thu, 06 Feb 2020 13:16:32 +0000 |
| Subject: | Bug #79235 [Opn->Dup]: Large consumption of memory when using a user filter | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-225387@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79235&edit=1
ID: 79235
Updated by: nikic@php.net
Reported by: thomas dot gerbet at enalean dot com
Summary: Large consumption of memory when using a user filter
-Status: Open
+Status: Duplicate
Type: Bug
Package: Streams related
Operating System: Linux
PHP Version: 7.3.14
Block user comment: N
Private report: N
New Comment:
Duplicate of bug #78902, which is already fixed in the upcoming releases.
Previous Comments:
------------------------------------------------------------------------
[2020-02-06 12:58:32] thomas dot gerbet at enalean dot com
Description:
------------
Since PHP 7.3.11 (it looks like it is the case since https://github.com/php/php-src/commit/05560b67bc87a2bcbfd5b48a48443a62f3311e7d)
processing a stream with a PHP user filter consumes at least the same amount of memory that the size
of the processed data. It was not the case before.
Test script:
---------------
<?php
$input_resource = fopen('/dev/zero', 'rb');
$dev_null = fopen('/dev/null', 'wb+');
class TestFilter extends \php_user_filter {
public function filter($in, $out, &$consumed, $closing)
{
while ($bucket = \stream_bucket_make_writeable($in)) {
$consumed += $bucket->datalen;
\stream_bucket_append($out, $bucket);
}
return PSFS_PASS_ON;
}
}
\stream_filter_register('testm', \TestFilter::class);
$input_with_filter = \stream_filter_prepend(
$input_resource,
'testm',
STREAM_FILTER_READ
);
stream_copy_to_stream($input_resource, $dev_null, 1 * 1024 * 1024 * 1024);
fclose($dev_null);
fclose($input_resource);
Expected result:
----------------
// No fatal error
Actual result:
--------------
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65019904
bytes) in example.php on line 24
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79235&edit=1