#39396 [NEW]: stream_set_blocking crashes
| From: | maurice at iceblog dot de | Date: | Mon, 06 Nov 2006 10:33:33 +0000 |
| Subject: | #39396 [NEW]: stream_set_blocking crashes | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-104458@lists.php.net to get a copy of this message | ||
From: maurice at iceblog dot de
Operating system: Windows XP
PHP version: 5.2.0
PHP Bug Type: Streams related
Bug description: stream_set_blocking crashes
Description:
------------
When you use stream_socket_client with asynchronous connect
(STREAM_CLIENT_ASYNC_CONNECT), but do not specify STREAM_CLIENT_CONNECT
then stream_set_blocking will crash PHP on Windows XP.
The documentation does NOT tell you to use
STREAM_CLIENT_ASYNC_CONNECT | STREAM_CLIENT_CONNECT.
I think STREAM_CLIENT_ASYNC_CONNECT should implicate
STREAM_CLIENT_CONNECT.
-- Possibility 1 to fix implication ---------
#define STREAM_XPORT_CONNECT 2
#define STREAM_XPORT_CONNECT_ASYNC 18 // instead of 16
#define PHP_STREAM_CLIENT_CONNECT 4
#define PHP_STREAM_CLIENT_ASYNC_CONNECT 6 // instead of 2
-- Possibility 2 to fix "implication" -------
Patch for 5.2.0 source (not CVS).
--- transports.c 2006-01-01 13:50:18.000000000 +0100
+++ transports-maurice.c 2006-11-06 11:18:49.000000000 +0100
@@ -136,7 +136,7 @@
if ((flags & STREAM_XPORT_SERVER) == 0) {
/* client */
- if (flags & STREAM_XPORT_CONNECT) {
+ if (flags & STREAM_XPORT_CONNECT || flags &
STREAM_XPORT_CONNECT_ASYNC) {
if (-1 == php_stream_xport_connect(stream, name, namelen,
flags & STREAM_XPORT_CONNECT_ASYNC ? 1 : 0,
timeout, &error_text, error_code TSRMLS_CC)) {
---------------------------------------------
There are other (somehow) related bugs:
http://bugs.php.net/bug.php?id=30386
http://bugs.php.net/bug.php?id=28245
Reproduce code:
---------------
<?php
$fp = stream_socket_client("tcp://www.php.net:80", $errno, $errstr,
30, STREAM_CLIENT_ASYNC_CONNECT);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
var_dump(stream_set_blocking($fp, false));
fclose($fp);
}
?>
Expected result:
----------------
If you do not specify STREAM_CLIENT_CONNECT in stream_socket_client the
socket never ever gets connected. Thus, stream_set_blocking should return
FALSE and throw an E_WARNING.
However, as this is a stream function and the stream is still considered
"valid", TRUE might also be all right.
Under Debian Linux (Sarge, Kernel 2.6.8) stream_set_blocking returns TRUE
(which I think is misleading).
Actual result:
--------------
Crashes under Windows XP; returns TRUE on Linux.
--
Edit bug report at http://bugs.php.net/?id=39396&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=39396&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=39396&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=39396&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=39396&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=39396&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=39396&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=39396&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=39396&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=39396&r=support
Expected behavior: http://bugs.php.net/fix.php?id=39396&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=39396&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=39396&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=39396&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=39396&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=39396&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=39396&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=39396&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=39396&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=39396&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=39396&r=mysqlcfg