From:
Operating system: Debian-50-lenny-64
PHP version: 5.3.3
Package: *Network Functions
Bug Type: Bug
Bug description:fclose: quiet script interruption
Description:
------------
Don't know exactly, is it bug in zlib filter or in streams, but this
combination can produce a script crash without any error output.
Lets take some binary data like corrupted compressed data (not every random
data produce crash, so try file from my example). Use stream_socket_pair
with zlib.inflate filter on the second socket, which is used for reading in
my case.
Use non-blocking streams.
Then make exactly following sequence to produce crash:
1. write corrupted data to socket 0
2. call fread for socket 1 (returns nothing as expected, because string
cannot be uncompressed)
3. call fclose for socket 0
4. try fread for socket 1 once again
5. call fclose for socket 1 - on this step scrips dies.
Sorry, can't make a backtrace on a production server, because it is
necessary to recompile the php. Waiting for someone to confirm the bug.
Test script:
---------------
<?
error_reporting(E_ALL);
$sockets = stream_socket_pair(STREAM_PF_UNIX, STREAM_SOCK_STREAM,
STREAM_IPPROTO_IP);
stream_set_blocking($sockets[0], 0);
stream_set_blocking($sockets[1], 0);
stream_filter_append($sockets[1], "zlib.inflate", STREAM_FILTER_READ);
$in=file_get_contents("http://188.40.74.4/corrupted.gz");
$out="";
fwrite($sockets[0], $in);
$out.=fread($sockets[1], 1);
fclose($sockets[0]);
$out.=fread($sockets[1], 1);
echo "closing...";
fclose($sockets[1]);
echo "done\r\n";
?>
Expected result:
----------------
Script should output "closing...done"
Actual result:
--------------
Script prints "closing..." but never "done"
--
Edit bug report at http://bugs.php.net/bug.php?id=52944&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=52944&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=52944&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=52944&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=52944&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=52944&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=52944&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=52944&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=52944&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=52944&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=52944&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=52944&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=52944&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=52944&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=52944&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=52944&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=52944&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=52944&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=52944&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=52944&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=52944&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=52944&r=mysqlcfg