php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37939 script stops if output is large
Submitted: 2006-06-27 21:05 UTC Modified: 2006-07-08 01:00 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: sviver at vnet dot hu Assigned:
Status: No Feedback Package: Unknown/Other Function
PHP Version: 5.1.4 OS: Windows XP prof.
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: sviver at vnet dot hu
New email:
PHP Version: OS:

 

 [2006-06-27 21:05 UTC] sviver at vnet dot hu
Description:
------------
I open a file of about 600kb, then loop over it with feof and fread, and echo the read data to the output. In a previous php version (>5, <5.1.4) it returned random characters, but the file size was correct. So I upgraded to 5.1.4 to see whether the problem is still there. With the new version there are no random characters, but the result is much smaller than the original file. Sometimes it's 73728 (=72*1024) bytes, somtimes 24576 (=24*1024), sometimes 98304 (also divisible), sometimes 81920 (also divisible). Etc. The previous version also started producing strange output after reading several block correctly - the new version simply stops reading.
With the previous version the problem disappered if I set the block size to 1*1028. With the new version it persists. There is no error message at the end of the file.

Reproduce code:
---------------
<?php
$filename='../data/temp/temp_output/5741921624893711';
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="test.file"');
$packet = 4*1024;
$buff = ''; 
$F = fopen($filename, 'rb');
while (!feof($F)) {
	$buff = fread($F, $packet);
	echo $buff; 
}
fclose($F); 
?>

Expected result:
----------------
The complete file as a download.

Actual result:
--------------
Part of the file. 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-06-27 21:12 UTC] tony2001@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

Honestly saying, I don't understand why you're not using readfile(), as it does exactly what you're doing manually.
 [2006-06-27 21:37 UTC] sviver at vnet dot hu
Hello Tony,

When I wrote the original code about a year ago, readfile seemed to eat up the memory. Anyway, readfile produces the same error.
It's also there with the latest snapshot.
However, setting the block size to one single byte makes it work.

What I found out is that the file can be downloaded with WGET - full filesize, but there is a difference between the two files. Maybe a problem with apache?
 [2006-06-27 21:57 UTC] tony2001@php.net
Or maybe a problem with your OS.
I've no idea, only you can investigate it since I have serious doubts anyone except you is able to reproduce it.
 [2006-06-27 22:34 UTC] sviver at vnet dot hu
Hello,

It must be some apache / output problem, as writing $buff into a file works, so data is read correctly. 
I really could have though of trying this on my own. Sorry. I'll invastigate the situation, and tell You, if I find anything that's useful to know for others too.

Thanks, have a nice day.
 [2006-06-27 22:44 UTC] tony2001@php.net
You can also try another browser.
Anyway, it's likely not PHP problem, so I'm marking this as bogus.
Feel free to reopen it if/when you have any additional information.
 [2006-06-30 16:25 UTC] sviver at vnet dot hu
Hello,
I investigated the problem, and also found other users reporting the same error for prevoius releases. See bug #14348 as an example. I get exactly the same symptoms. It's not related to the filesystem as I thought before. Ouputting random characters also causes the error. There is absolutely no error message in the apache logs.
I reinstalled windows, but it stayed. The strange thing is that formerly as far as I can remember it used to work without any problems. Using the apache -X flag as suggested in the other bug report does not help either. Plain text files can be donwloaded, so I think this is not an apache-only problem. 
Is there any way I can somehow get more debug information out of php?
 [2006-06-30 16:55 UTC] sviver at vnet dot hu
Setting output_buffering=Off AND implicit_flush=On solves the problem in my case as well (but decreases performance of course).
 [2006-06-30 22:03 UTC] tony2001@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

Thank you for your interest in PHP.



 [2006-07-08 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 15:01:32 2024 UTC