#45392 [Asn->Csd]: ob_start()/ob_end_clean() and memory_limit

From: Date: Wed, 17 Sep 2008 00:20:53 +0000
Subject: #45392 [Asn->Csd]: ob_start()/ob_end_clean() and memory_limit
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-129042@lists.php.net to get a copy of this message
 ID:               45392
 Updated by:       iliaa@php.net
 Reported By:      flebron at bumeran dot com
-Status:           Assigned
+Status:           Closed
 Bug Type:         Output Control
 Operating System: Fedora Linux 2
 PHP Version:      5.3CVS-2008-06-29 (snap)
 Assigned To:      lbarnaud
 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:
------------------------------------------------------------------------

[2008-08-18 07:47:20] tony2001@php.net

The patch caused prolems and has been reverted.

------------------------------------------------------------------------

[2008-08-18 04:13:36] lbarnaud@php.net

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.



------------------------------------------------------------------------

[2008-07-14 11:26:09] jani@php.net

This slightly modified script shows the bug without massive output:

<?php
ini_set('memory_limit', 100);
ob_start();
$i = 0;
while($i++ < 5000)  {
  echo str_repeat("lol", 42);
}
ob_end_clean();
?>


------------------------------------------------------------------------

[2008-06-29 22:30:08] flebron at bumeran dot com

Description:
------------
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.

Reproduce code:
---------------
<?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

STDOUT: Nothing

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 http://bugs.php.net/?id=45392&edit=1



Thread (12 messages)

« previous php.bugs (#129042) next »