Bug #66928 [Fbk->NoF]: ob_start()/ob_end_clean() and memory_limit
| From: | php-bugs at lists dot php dot net | Date: | Tue, 30 Dec 2014 10:42:29 +0000 |
| Subject: | Bug #66928 [Fbk->NoF]: ob_start()/ob_end_clean() and memory_limit | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-189471@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=66928&edit=1
ID: 66928
Updated by: php-bugs@lists.php.net
Reported by: leon at struktur dot de
Summary: ob_start()/ob_end_clean() and memory_limit
-Status: Feedback
+Status: No Feedback
Type: Bug
Package: Output Control
Operating System: *
PHP Version: Irrelevant
Private report: N
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2014-07-06 02:14:52] yohgaki@php.net
[yohgaki@dev PHP-5.5]$ cat t.php
<?php
ob_start();
$i = 0;
while($i++ < 1024*4) {
echo str_repeat("a", 1024);
}
ob_end_clean();
?>
END
[yohgaki@dev PHP-5.5]$ ./php-bin -d error_reporting=-1 -d memory_limit=400000 t.php
Fatal error: Allowed memory size of 400000 bytes exhausted at
/home/yohgaki/git/oss/php.net/PHP-5.5/Zend/zend_stack.c:37 (tried to allocate 512 bytes) in
/home/yohgaki/workspace/ext/git/oss/php.net/PHP-5.5/t.php on line 4
It seems working correctly.
Are you sure you have reached memory_limit?
------------------------------------------------------------------------
[2014-07-06 02:14:42] yohgaki@php.net
[yohgaki@dev PHP-5.5]$ cat t.php
<?php
ob_start();
$i = 0;
while($i++ < 1024*4) {
echo str_repeat("a", 1024);
}
ob_end_clean();
?>
END
[yohgaki@dev PHP-5.5]$ ./php-bin -d error_reporting=-1 -d memory_limit=400000 t.php
Fatal error: Allowed memory size of 400000 bytes exhausted at
/home/yohgaki/git/oss/php.net/PHP-5.5/Zend/zend_stack.c:37 (tried to allocate 512 bytes) in
/home/yohgaki/workspace/ext/git/oss/php.net/PHP-5.5/t.php on line 4
It seems working correctly.
Are you sure you have reached memory_limit?
------------------------------------------------------------------------
[2014-03-18 20:22:49] leon at struktur dot de
New test script:
$img = @imagecreatefromstring(file_get_contents($file));
if($img !== false)
{
imagealphablending($img, false);
imagesavealpha($img, true);
ob_start();
imagepng($img);
$img_content = ob_get_clean();
imagedestroy($img);
$img_content = base64_encode($img_content);
return $img_content;
}
Output: "* PNG IHDR**"
New test #2 script:
$img = @imagecreatefromstring(file_get_contents($file));
if($img !== false)
{
imagealphablending($img, false);
imagesavealpha($img, true);
ob_start();
echo 'LALALA';
imagepng($img);
$img_content = ob_get_clean();
imagedestroy($img);
$img_content = base64_encode($img_content);
return $img_content;
}
Output: "LALALA* PNG IHDR**"
BTW: It works (I get no output) when I add ini_set('memory_limit', '-1');
------------------------------------------------------------------------
[2014-03-18 19:56:50] leon at struktur dot de
Description:
------------
COPY FROM : https://bugs.php.net/bug.php?id=45392
STILL NOT FIXED, BUT BUG IS CLOSED !!
When memory_limit is reached, and one is using the output buffering functions, instead of just dying
with an "out of memory" error, the contents of the buffer are spilled onto stdout.
The output_buffering ini setting wasn't set to any particular limit.
Test script:
---------------
<?php
ob_start();
$i = 0;
while($i++ < 10000000) {
echo str_repeat("lol", 42);
}
ob_end_clean();
/*Note that the 10,000,000 number varies according to your memory_limit*/
Expected result:
----------------
STDERR: Fatal error: Allowed memory size of 134217728 bytes exhausted at
/home/flebron/cvs/php/php5.3-200806291230/main/output.c:395 (tried to allocate 133693441 bytes) in
/home/flebron/cvs/php/ob.php on line 5
Actual result:
--------------
STDERR: Fatal error: Allowed memory size of 134217728 bytes exhausted at
/home/flebron/cvs/php/php5.3-200806291230/main/output.c:395 (tried to allocate 133693441 bytes) in
/home/flebron/cvs/php/ob.php on line 5
STDOUT: The text in the buffer is printed to stdout (millions of "lolol"s).
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=66928&edit=1