From:             victor-php at boivie dot com
Operating system: FreeBSD 4.7
PHP version:      5.0.0
PHP Bug Type:     Filesystem function related
Bug description:  readfile (or fpassthru or even php_stream_passthru) can not output 
large++ file

Description:
------------
victor:~> php -v
PHP 5.0.0RC2 (cgi) (built: Apr 30 2004 08:15:25)

(oh well, this issue still exists in 5.0.0)

victor:~> grep output /usr/local/lib/php.ini
<snip>
output_buffering = 4096
<snip>
output_handler =
<snip>
zlib.output_compression = Off

victor:~> ls -l test.fil 
-rw-r--r--  1 root  wheel  734939136 Oct 14  2003 test.fil

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

As the results shows, PHP tries to allocate the whole file in memory which
is bad. I thought php_stream_passthru used a small buffer and that it
didn't allocate the whole file, but I'm not familiar with the PHP source
code. 


Reproduce code:
---------------
<?php
  readfile("test.fil");
?>


Expected result:
----------------
A lot of file data in the browser window (the file contents)

Actual result:
--------------
PHP Fatal error:  Out of memory: cannot allocate 734941208 bytes! in
/usr/home/victor/foo.php on line 2
Content-type: text/html
X-Powered-By: PHP/5.0.0RC2

<br />
<b>Fatal error</b>:  Out of memory: cannot allocate 734941208 bytes! in
<b>/usr/home/victor/foo.php</b> on line <b>2</b><br />


-- 
Edit bug report at http://bugs.php.net/?id=29159&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=29159&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=29159&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=29159&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=29159&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=29159&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=29159&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=29159&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=29159&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=29159&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=29159&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=29159&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=29159&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29159&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=29159&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=29159&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=29159&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29159&r=float

Reply via email to