php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21262 crash or fail when outputting large amounts of text quickly
Submitted: 2002-12-29 00:05 UTC Modified: 2003-02-04 20:22 UTC
Votes:7
Avg. Score:3.3 ± 1.6
Reproduced:4 of 6 (66.7%)
Same Version:2 (50.0%)
Same OS:4 (100.0%)
From: spagmoid at yahoo dot com Assigned:
Status: Closed Package: Performance problem
PHP Version: 4.3.0 OS: WinXP
Private report: No CVE-ID: None
 [2002-12-29 00:05 UTC] spagmoid at yahoo dot com
On the SAPI version of php in Apache under WinXP:

for($Loop=0 ; $Loop<100000 ; $Loop++)
{
	echo "blah $Loop ";
}

(usually) causes IE to abort loading and reload the page many times; eventually it just shows the standard "The page cannot be displayed", "Cannot find server or DNS Error".

Netscape simply aborts in the middle, usually around 50,000.  But, sometimes it works fine.

If you add a flush() in the loop, the problem goes away.
Nothing shows up in the PHP or server error logs, so I assume its a crash.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-29 12:01 UTC] spagmoid at yahoo dot com
Setting implicit_flush to ON does not fix it - so maybe adding flush() only helps because it slows it down..?

Also, messing with output_buffering has no effect.

This problem has been present ever since I started using PHP.  Maybe a memory overflow?
Can anyone else repro? (note this only happens with the sapi/mod version)
 [2002-12-29 14:08 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

I think this is not a bug, but simply an issue of running out of memory, because the data in the buffer simply gets too big. flush() dumps the data inside the buffer to screen and clears the buffer, which is why it wouldn't crash when flush() is used.
 [2002-12-29 15:26 UTC] spagmoid at yahoo dot com
Then maybe this should be a doc change: "If you don't call flush() once in a while, PHP will hang.  This is not a bug.  Hanging is intentional."

This is a BUG.  If it causes PHP to HANG before outputting the page, then it is a BUG!  FLUSH IS NOT SUPPOSED TO BE MANDATORY.

This also happens when outputting pages under 20K, but this example is the best way to repro.  And as I stated, implicit flushing does not fix the problem either.  Any delay in the loop fixes it.

Every time I submit something here, somebody spends 15 seconds on it and marks it as bogus.  When it is NOT.  I WENT TO THE TIME OF SUBMITTING THIS FOR A REASON, AND I AM NOT A JACKASS.  I HAVE BEEN PROGRAMMING FOR 15 YEARS.  If you treat every bug report on here like an idiot wrote it, only idiots are going to stick around to report "bugs" for you.  Spend a little more than 15 seconds on it.

I gave exact details and the simplest repro on earth, not to mention the results of possible contributing factors.  What else could you possibly want.  Why is it so hard to get problems even acknowledged here?  Maybe I should just mark them as bogus in the beginning to save a little time.  This is as bad as reporting bugs to Microsoft.
 [2002-12-30 10:05 UTC] ssjslim at yahoo dot com
This does not seem to be a problem. I can not reproduce this crash with the following code.

for($Loop=0 ; $Loop<100000000 ; $Loop++)
{
	echo "blah $Loop ";
}

I am also using the SAPI version of PHP in Apache under Windows XP.
 [2002-12-30 15:45 UTC] spagmoid at yahoo dot com
Well that's strange, can anyone else repro this?  You may need to refresh a few times for it to happen.  I have been using PHP from the command line for the last year because of this issue.
 [2003-01-10 20:58 UTC] b at brentc dot com
I had the exact same problem.  I submitted a bug report.  Bug smashers seemed to go off on some random tangent.  Then decided all of a sudden that it was an IE problem (even though in my original report I clearly stated that there was a problem with Mozilla/Netscape output as well).

My original bug report here:
http://bugs.php.net/bug.php?id=14474
 [2003-01-10 23:42 UTC] spagmoid at yahoo dot com
Ridiculous.. how on earth can they look at this:

PHP Fatal error:  Allowed memory size of 8388608
bytes exhausted (tried to allocate 10240 bytes)

And say its a bug in IE?
I agree with the first assesment - this is a likely a CRITICAL bug.  I have seen pages fail for no reason on linux too, who knows if this problem could be responsible.  This needs to be looked at by someone at the top.
 [2003-01-14 13:34 UTC] gmeakin at btinternet dot com
I can confirm this bug including the for loop provided earlier in this bug thread.

I am using php 4.3.0 with Apache 2.0.43 with Windows XP Home Edition.

I found this bug report after noticing the same effect with a large piece of php that I have been writing. I have found that turning off error reporting in php.ini helps but does not solve the problem totally. I found that using the flush() function helped but was not a reliable solution.

This seems a blatant problem which is making debugging and development almost impossible and very frustrating. Is there any update on confirming the bug?

Regards
 [2003-01-14 19:25 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-STABLE-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-STABLE-latest.zip


(and what apache version is it?)

 [2003-01-15 16:44 UTC] gmeakin at btinternet dot com
I am using Apache version 2.0.43 with the sapi php module.

I downloaded the latest stable snapshot of php (4.3.1) but it still reproduced the same orignial problem discussed.

Regards
 [2003-01-16 10:20 UTC] spagmoid at yahoo dot com
This bug has been present for over a year, maybe since the beginning of PHP.  We're still getting people passing the buck..
 [2003-01-22 17:12 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

I've explained before and I will attempt to explain once again. When output buffering is turned on the system does not output the text right away but rather fills up a memory buffer that is displayed in one large block. If the text you are trying to output exceeds the avaliable system memory then the error you are seeing will occur. This cannot be helped, the solution is to either disable output buffering or not use things like gz_handler, which cause ALL of the output to be buffered in memory rather then output the data in chunks (default chunk size 4096 bytes).
 [2003-01-22 19:41 UTC] spagmoid at yahoo dot com
You are wrong.
If it was a memory error, PHP should display the standard out of memory message.

AS I EXPLAINED, this also happens with very SMALL amounts of data.  The use of large blocks of data is just an easy way to REPRO.  Surely there must be more people working on PHP than you?
 [2003-01-22 19:47 UTC] sniper@php.net
Please provide a SHORT but complete example script that
can be used to reproduce this. (the one you provided doesn't cause any crashes)

 [2003-01-22 19:49 UTC] spagmoid at yahoo dot com
This is not always reproducible, this is as good as we can come up with.  It appears to only reproduce for people unwilling to do anything about it.
 [2003-01-22 19:55 UTC] sniper@php.net
You really need to correct your attitude first.
We're all volunteers here and don't get paid for
this shit..

 [2003-01-22 20:13 UTC] spagmoid at yahoo dot com
My attitude is a result of iliaa's disrespect for MY time and work on this.  I have nothing but respect for people that volunteer to improve PHP.  Like I am doing myself by trying to point out bugs.  I don't get paid to try OVER AND OVER to get people to recognize problems, and it is less fun than just fixing them myself would be, I assure you.  But I have other projects I am committed to.  The most I can do is keep pushing through the bureaucratic atmosphere created by people more interesting in closing bugs than fixing them.  

As I mentioned before, it's very much like trying to get bugs fixed at Microsoft.  I don't know why, but this open source project has managed to duplicate the beauracracy aspect of large corporations very well.  Perhaps its a lack of accountability from the lack of personal code ownership.

Anyway, I submit to you that in NO CASE should PHP exit in an error condition without showing an error message.  If this is INTENDED behavior then let me see the words "memory exceeded, quitting".  Until I see them, this is a bug.

In fact, I very much doubt that this is intended behavior.  When the buffer is full, PHP waits for it to be transmitted then continues.  It does not simply crash.  

To state that crashing is "not a bug" shows a fundamental misunderstanding of programming, and indeed of the difference between all that is good and evil.
 [2003-01-28 13:27 UTC] gmeakin at btinternet dot com
I have managed to solve my problem with outputting large amounts of data under WinXP Home Edition, PHP 4.3.0 and Apache 2.0.44. 

I experienced this problem consistently with a php page that I had written. I installed Windows XP Service Pack-1 from Microsoft and it fixed the problem straight away. To convince myself further I tried the php script listed at the beginning of this bug thread which I previously experienced the same problem. This also works with the service pack installed.

It looks like a bug on Microsoft's side of the fence. Try installing the service pack for yourself and email this thread with your results as it worked for me.

Good luck.
Regards
 [2003-01-29 00:06 UTC] sniper@php.net
Does the solution provided by gmeakin@btinternet.com 
fix the problem for you..?


 [2003-02-03 11:32 UTC] gmeakin at btinternet dot com
[Update]
Just to confirm further after many more hours of use that installing Micrsoft's WinXP Service Pack-1 has fixed this bug for me.
 [2003-02-03 22:45 UTC] spagmoid at yahoo dot com
I can't install SP1 here, but I wouldn't be surprised.

This does counter iliaa's "by design" theory.
 [2003-02-04 05:19 UTC] sniper@php.net
Why can't you install that SP1??
Others reported it fixes this issue, so..

 [2003-02-04 20:22 UTC] spagmoid at yahoo dot com
We have heard of unrelated issues with SP1, and with M$ there's no going back.  We will upgrade eventually, but I will accept this as resolved since others have reported this fix.  Thanks to gmeakin!
 [2003-03-21 01:10 UTC] at NONSPAMvertigomega at SPAMMENOTshaw dot ca at
I am currently running Windows XP PRO, upgraded with Service Pack 1, and I'd like to report an ackward situation, just for people who may still be encountering this situation:

ENABLE output buffering in PHP.

Myself, and a friend, both running the same version of WindowsXP experienced problems with a page.  After enabling output buffering, all was alright.

Running on Slackware 8.1, Apache 2.0...Don't know the specific builds ATM.  I'm just making sure that people know that basically they should diddle with output buffering before going any further.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 06:01:30 2024 UTC