From:
Operating system: CentOS 4.8
PHP version: 5.2.14
Package: Streams related
Bug Type: Bug
Bug description:fpassthru causes early script termination with no errors
Description:
------------
I am using PHP 5.2.14 built from source on CentOS 4.8. This also happens in
PHP
5.2.13.
Basically what is happening is that if I run the following code (from a web
address, not CLI), and terminate before sleep() is done performing, I do
not see
the last error_log(). I only see the one before fpassthru(). This only
happens
when $content is very large (not sure how large, but my script was using
~15MB
string).
It appears that if I add ob_start() and ob_end_flush() around the script,
everything performs correctly, even if I terminate the script early.
I have already verified that the content is in fact being written to $file
just
fine. I manually checked the file and also called file_get_contents() after
file_put_contents() and the data came back just fine.
Again, I receive no errors in the PHP error log or Apache log (e.g. no
segfaults).
Test script:
---------------
// $content must be much larger than this sample...something like 15MB of
base64
// encoded data will do the trick.
$content = 'JVBERi0xLjQKJeTjz9IKNjMgMCBvYmoKPDwKL0xpbmVhcm';
file_put_contents($file, $content); // $file is a valid full file
path/name
$fp = fopen($file, 'r');
sleep(5); // This is only here to aid in terminating the script before
fpassthru() is called.
error_log('Error log before fpassthru() is called!');
$characterCount = fpassthru($fp);
error_log(var_export($characterCount, true));
Expected result:
----------------
I would expect fpassthru() to not totally kill the script. Even though the
client
will not see the contents of fpassthru(), the rest of the script should
still
perform as expected.
Actual result:
--------------
The script terminates before the last error_log is called and no errors are
displayed, no segfaults reported, etc., even when the highest PHP error
logging is
enabled.
--
Edit bug report at http://bugs.php.net/bug.php?id=52918&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=52918&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=52918&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=52918&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=52918&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=52918&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=52918&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=52918&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=52918&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=52918&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=52918&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=52918&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=52918&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=52918&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=52918&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52918&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52918&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=52918&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=52918&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=52918&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=52918&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=52918&r=mysqlcfg