|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull Requests
Pull requests:
HistoryAllCommentsChangesGit/SVN commits
[2019-12-03 23:10 UTC] cmb@php.net
[2019-12-04 14:18 UTC] leopold dot jacquot at gmail dot com
[2019-12-16 09:29 UTC] cmb@php.net
[2020-01-14 08:27 UTC] iretemd at gmail dot com
[2020-01-14 08:28 UTC] bugreports at gmail dot com
[2020-01-22 21:23 UTC] fredrik dot lindvall at unx dot nu
[2020-01-23 13:58 UTC] nikic@php.net
[2020-01-23 13:58 UTC] nikic@php.net
-Status: Open
+Status: Closed
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 17:00:01 2025 UTC |
Description: ------------ When using stream_filter_append, used memor increase until a Fatal error: Allowed memory error occurred. This bug appears on PHP 7.3.11 and greater. To reproduce, you will need to have the script test.php and a large file (here named file.txt). If needed, you can create a dummy blank file with this command (unix) dd if=/dev/urandom of=file.txt bs=1048576 count=100 For easier test, I used official docker image and mount a folder with this two files. In the actual result, you will see that the memory usage is increasing until a fatal error occurred. In the expected result, you will see that the memory usage is stable all the long of the file reading. You can reproduce the expected result using the php:7.3.10-cli docker image. Test script: --------------- docker run -it --rm -v "/home/public":/usr/src/myapp -w /usr/src/myapp php:7.4.0-cli php test.php <?php /** test.php **/ class useless_filter extends php_user_filter { function filter($in, $out, &$consumed, $closing) { while ($bucket = stream_bucket_make_writeable($in)) { $consumed += $bucket->datalen; stream_bucket_append($out, $bucket); } echo memory_get_usage() . "\n"; return PSFS_PASS_ON; } } stream_filter_register("useless", "useless_filter") or die("Failed to register filter"); $fp = fopen("file.txt", "r"); stream_filter_append($fp, "useless"); while (!feof($fp)) { fread($fp, 8192); } fclose($fp); Expected result: ---------------- 431784 431784 431784 431784 431784 431784 431784 431784 431784 423544 Actual result: -------------- 65287872 65296064 65304256 65312448 65320640 65328832 65337024 65345216 65353408 65361600 65369792 65377984 65386176 65394368 65402560 65410752 65418944 65427136 65435328 Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 65019904 bytes) in /usr/src/myapp/filter.php on line 39