ID: 22474
Comment by: kxrm at hotmail dot com
Reported By: chuck at fuck dot org
Status: No Feedback
Bug Type: Filesystem function related
Operating System: FreeBSD 4.7
PHP Version: 5CVS-2003-02-28 (dev)
New Comment:
I thought at first this would occur only with large fwrites but it also
occurs under any situation where the server on the other end closes the
connection.
To reproduce just fwrite a large amount of data to another TCP server
and while it's in the process of fwriting (in some while loop) close
the server on the other end.
Previous Comments:
------------------------------------------------------------------------
[2003-11-04 07:29:09] kxrm at hotmail dot com
I am also experiencing this problem with Redhat 7.3
I do not have a debug install however but here are the results of the
backtrace.
Program received signal SIGPIPE, Broken pipe.
[Switching to Thread 1024 (LWP 11094)]
0x420e83b2 in send () from /lib/i686/libc.so.6
(gdb) bt full
#0 0x420e83b2 in send () from /lib/i686/libc.so.6
No symbol table info available.
#1 0x08176350 in php_sockop_write ()
No symbol table info available.
#2 0x0817296d in _php_stream_write ()
No symbol table info available.
#3 0x0811a67a in zif_fwrite ()
No symbol table info available.
#4 0x081a6321 in execute ()
No symbol table info available.
#5 0x08192ee8 in zend_execute_scripts ()
No symbol table info available.
#6 0x08169681 in php_execute_script ()
No symbol table info available.
#7 0x081b64bc in main ()
No symbol table info available.
#8 0x42017589 in __libc_start_main () from /lib/i686/libc.so.6
No symbol table info available.
It doesn't lockup when in gdb it just displays the broken pipe error,
but when running normally it does lockup.
------------------------------------------------------------------------
[2003-03-16 01:00:01] php-bugs at lists dot php dot net
No feedback was provided for this bug for over 2 weeks, 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".
------------------------------------------------------------------------
[2003-02-28 10:31:45] [EMAIL PROTECTED]
Can you provide a bit more information?
I want to see a script like this:
<?php
$fp = fsockopen($host, $port, $err, $errstr, 10);
if (!$fp) {
die("Connection failed: $err $errstr);
}
stream_set_timeout($fp, 15);
$n = fwrite($fp, "data");
var_dump($n);
fclose($fp);
?>
But please fill in the $host and $port with addresses that I can use
from my machine(s) so that I can try and replicate.
Alternatively, please read the docs here
http://bugs.php.net/bugs-generating-backtrace.php
and generate a backtrace from within the fwrite() when it is eating up
the cpu:
Compile php with --enable-debug first then:
gdb ./sapi/cli/php
run myscript.php
[ wait for it to "hang" ]
[ press CTRL-C ]
bt full
Please post the backtrace at a URL and enter the link into this
report.
If you can provide a reproducing script AND a backtrace, that is even
more useful.
------------------------------------------------------------------------
[2003-02-28 06:34:23] chuck at fuck dot org
When using a fsockopen resource that has been accepted, but is
non-responsive, fwrite will use as much cpu as it can before the
program is terminated by the time limit.
if(false===([EMAIL PROTECTED]("tcp://$a", 1080, $err, $errstr, 10)))
return false;
$conn=pack('ccnN', '4', 1, 25, ip2long($ip)) .pack('a',$socksusers);
stream_set_timeout($a, 15);
if(!socks_write($a,$conn,9)) return false;
function socks_write(&$a,$b,$c=false) {
$tmp=fwrite($a,$b,$c);
if($c != $tmp) return false;
return true;
}
This program will freeze at the fwrite command.
I've had this happen on PHP 4.3.0 and CVS
It only occurs when specific servers are addressed in the fsockopen.
While I understand the server may be responding with garbage data, the
fsockopen should not be returning the connection as success. Even with
that case, I don't see reason for the fwrite to hang with high cpu
usage.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=22474&edit=1