#22154 [Opn]: fpassthru() fails with files larger than a few hundered KB

From: Date: Tue, 11 Feb 2003 04:47:33 +0000
Subject: #22154 [Opn]: fpassthru() fails with files larger than a few hundered KB
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-32733@lists.php.net to get a copy of this message
 ID:               22154
 Updated by:       sas@php.net
 Reported By:      malekjo@aphrodite.com
 Status:           Open
 Bug Type:         Apache related
 Operating System: Linux 2.4.18-10
 PHP Version:      4.3.0
 New Comment:

The compatibility issue with the IBM HTTP Server has been resolved.
Appropiate solutions are available as part of all main branches.


Previous Comments:
------------------------------------------------------------------------

[2003-02-10 22:33:28] malekjo@aphrodite.com

Try this:

<?php

session_start();

$fp = fopen('SOMELARGETEXTFILE','r');

if ($fp)
  {
      fpassthru($fp);
  }

else
  {
      echo "file not found\n";
  }
?>

The reproducable error that fails for me no matter what.

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

[2003-02-10 22:11:57] malekjo@aphrodite.com

After a whole lot more testing tonight, I've discovered a few nasty
annoying things.

Outline of what I'm trying to do:

A self serve support center for users.
Users login into a session
Session checkes user credentials in an LDAP directory
Session variables stored in MySQL database
From the support site users may download patches & updates
Users can open a support request.

So, nothing too weird.  If I comment out all of my session material it
works. Using any session handling functions downloads work up to 1MB. 
If I comment out the LDAP authentication, the behavior is the same.  If
I comment out the MySQL handler and use the PHP default file handler,
the behavior is the same.  If I comment out the session handling, the
LDAP authentication and the DBMS stuff the downloads work.

I've gotten the Apache thread to exit and dump all the contents of all
the script variables to the web browser screen with no core dump.

All this indicates to me something in the PHP session handling is
stampling memory allocations.  Especially since I've gotten the same
results using an fread() loop instead of fpassthru().

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

[2003-02-10 18:40:07] hedd@nospam.momentum.com.au

From the testing I have done, files smaller than one meg seem to work
fine, but large files break in the manner described below.

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

[2003-02-10 18:36:16] malekjo@aphrodite.com

Can't build snapshot as apache mod...

Here's the error:

/bin/sh /home/joem/php/php4-STABLE-200302102230/libtool --mode=compile
gcc -I/opt/IBMHTTPServer/include -Isapi/apache/
-I/home/joem/php/php4-STABLE-200302102230/sapi/apache/ -DPHP_ATOM_INC
-I/home/joem/php/php4-STABLE-200302102230/include
-I/home/joem/php/php4-STABLE-200302102230/main
-I/home/joem/php/php4-STABLE-200302102230
-I/home/joem/php/php4-STABLE-200302102230/Zend -I/usr/include/libxml2
-I/usr/include/imap -I/home/joem/php/ldap/include
-I/home/joem/php/libmcal -I/usr/local/include
-I/home/joem/php/mysql/include/mysql -I/usr/include/ucd-snmp
-I/home/joem/php/php4-STABLE-200302102230/ext/xml/expat  -DLINUX=22
-DUSE_HSREGEX -DUSE_EXPAT
-I/home/joem/php/php4-STABLE-200302102230/TSRM  -g -Wall  -prefer-pic
-c /home/joem/php/php4-STABLE-200302102230/sapi/apache/mod_php4.c -o
sapi/apache/mod_php4.lo 
gcc -I/opt/IBMHTTPServer/include -Isapi/apache/
-I/home/joem/php/php4-STABLE-200302102230/sapi/apache/ -DPHP_ATOM_INC
-I/home/joem/php/php4-STABLE-200302102230/include
-I/home/joem/php/php4-STABLE-200302102230/main
-I/home/joem/php/php4-STABLE-200302102230
-I/home/joem/php/php4-STABLE-200302102230/Zend -I/usr/include/libxml2
-I/usr/include/imap -I/home/joem/php/ldap/include
-I/home/joem/php/libmcal -I/usr/local/include
-I/home/joem/php/mysql/include/mysql -I/usr/include/ucd-snmp
-I/home/joem/php/php4-STABLE-200302102230/ext/xml/expat -DLINUX=22
-DUSE_HSREGEX -DUSE_EXPAT
-I/home/joem/php/php4-STABLE-200302102230/TSRM -g -Wall -c
/home/joem/php/php4-STABLE-200302102230/sapi/apache/mod_php4.c  -fPIC
-DPIC -o sapi/apache/mod_php4.lo
/home/joem/php/php4-STABLE-200302102230/sapi/apache/mod_php4.c: In
function `sapi_apache_get_fd':
/home/joem/php/php4-STABLE-200302102230/sapi/apache/mod_php4.c:354:
structure has no member named `fd'
make: *** [sapi/apache/mod_php4.lo] Error 1

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

[2003-02-10 18:17:58] malekjo@aphrodite.com

Sorry for the delay, I was building php4.3.0 and monkeying with my
script for a bit.  A simplified:

function download_product ($product, $platform, $userdn) {

  $fp = fopen("/home/joem/public_html/php/wordlist.txt","r");
  fpassthru($fp);
}

exhibits the same problem.

But

<?php
  echo "<HTML><BODY><PRE>\n";
  $fp = fopen("somelargetextfile.txt","r");
  fpassthru($fp);
  echo "</PRE></BODY></HTML>\n";
?>

by itself starts printing the file to my browser fine...  I've still
got the fpassthru() running in the immediately above code running on
another box at the moment.

-rw-rw-r--    1 joem     joem         6.8M Feb 10 16:42
/home/joem/public_html/php/wordlist.txt

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

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/22154

-- 
Edit this bug report at http://bugs.php.net/?id=22154&edit=1



Thread (34 messages)

« previous php.bugs (#32733) next »