|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79235 Large consumption of memory when using a user filter
Submitted: 2020-02-06 12:58 UTC Modified: 2020-02-06 13:16 UTC
From: thomas dot gerbet at enalean dot com Assigned:
Status: Duplicate Package: Streams related
PHP Version: 7.3.14 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: thomas dot gerbet at enalean dot com
New email:
PHP Version: OS:


 [2020-02-06 12:58 UTC] thomas dot gerbet at enalean dot com
Since PHP 7.3.11 (it looks like it is the case since 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:

$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(

stream_copy_to_stream($input_resource, $dev_null, 1 * 1024 * 1024 * 1024);


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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-02-06 13:16 UTC]
-Status: Open +Status: Duplicate
 [2020-02-06 13:16 UTC]
Duplicate of bug #78902, which is already fixed in the upcoming releases.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 17 15:01:28 2024 UTC