php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #20874 socket_read on Multihomed Windows XP crashes PHP
Submitted: 2002-12-07 03:24 UTC Modified: 2003-02-06 03:35 UTC
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:0 of 1 (0.0%)
From: chip at cyan dot com Assigned:
Status: Not a bug Package: Sockets related
PHP Version: 4.3.0RC2 OS: Windows XP
Private report: No CVE-ID: None
 [2002-12-07 03:24 UTC] chip at cyan dot com
I have written a couple OO-PHP based TCP clients for a Proprietary PHP Socket Server that create a web based interface to certin aspects of an unnamed server.

This week, we had some hardware trouble, and we ended up moving one server to Windows XP instead of Windows 2000.  It was a clean format.(new hd)

After some intial re-installation, I have found, that anytime I call the socket_read function PHP promptly crashes.  The exact same code worked on the same hardware running windows 2000, and the code also works completely on Slackware-9.0(current).

The only thing that is unquie about this server is that it is Multihomed to about 30 different IP addresses.

This is repeatable. 100% everytime, using Apache2 Module, Apache13 Module, and the CLI interfaces to PHP.

The example script for a TCP Client on the Sockets Documentation also crashes PHP:
<?php
error_reporting (E_ALL);

echo "<h2>TCP/IP Connection</h2>\n";

/* Get the port for the WWW service. */
$service_port = getservbyname ('www', 'tcp');

/* Get the IP address for the target host. */
$address = gethostbyname ('www.example.com');

/* Create a TCP/IP socket. */
$socket = socket_create (AF_INET, SOCK_STREAM, 0);
if ($socket < 0) {
    echo "socket_create() failed: reason: " . socket_strerror ($socket) . "\n";
} else {
    echo "OK.\n";
}

echo "Attempting to connect to '$address' on port '$service_port'...";
$result = socket_connect ($socket, $address, $service_port);
if ($result < 0) {
    echo "socket_connect() failed.\nReason: ($result) " . socket_strerror($result) . "\n";
} else {
    echo "OK.\n";
}

$in = "HEAD / HTTP/1.0\r\n\r\n";
$out = '';

echo "Sending HTTP HEAD request...";
socket_write ($socket, $in, strlen ($in));
echo "OK.\n";

echo "Reading response:\n\n";
while ($out = socket_read ($socket, 2048)) {
    echo $out;
}

echo "Closing socket...";
socket_close ($socket);
echo "OK.\n\n";
?>

It gets to the echo "Reading response:\n\n"; and then PHP crashes, and I get the Windows XP message asking if I would like to send Microsoft a bug report. I have several times. Maybe they will respond :-)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-07 04:21 UTC] chip at cyan dot com
I have written a couple OO-PHP based TCP clients for a Proprietary PHP
Socket Server that create a web based interface to certin aspects of an
unnamed server.

This week, we had some hardware trouble, and we ended up moving one
server to Windows XP instead of Windows 2000.  It was a clean
format.(new hd)

After some intial re-installation, I have found, that anytime I call the
socket_read function PHP promptly crashes.  The exact same code worked
on the same hardware running windows 2000, and the code also works
completely on Slackware-9.0(current).

The only thing that is unquie about this server is that it is Multihomed
to about 30 different IP addresses.

This is repeatable. 100% everytime, using Apache2 Module, Apache13
Module, and the CLI interfaces to PHP.

The example script for a TCP Client on the Sockets Documentation also
crashes PHP:
<?php
error_reporting (E_ALL);

echo "<h2>TCP/IP Connection</h2>\n";

/* Get the port for the WWW service. */
$service_port = getservbyname ('www', 'tcp');

/* Get the IP address for the target host. */
$address = gethostbyname ('www.example.com');

/* Create a TCP/IP socket. */
$socket = socket_create (AF_INET, SOCK_STREAM, 0);
if ($socket < 0) {
    echo "socket_create() failed: reason: " . socket_strerror ($socket)
. "\n";
} else {
    echo "OK.\n";
}

echo "Attempting to connect to '$address' on port '$service_port'...";
$result = socket_connect ($socket, $address, $service_port);
if ($result < 0) {
    echo "socket_connect() failed.\nReason: ($result) " .
socket_strerror($result) . "\n";
} else {
    echo "OK.\n";
}

$in = "HEAD / HTTP/1.0\r\n\r\n";
$out = '';

echo "Sending HTTP HEAD request...";
socket_write ($socket, $in, strlen ($in));
echo "OK.\n";

echo "Reading response:\n\n";
while ($out = socket_read ($socket, 2048)) {
    echo $out;
}

echo "Closing socket...";
socket_close ($socket);
echo "OK.\n\n";
?>

It gets to the echo "Reading response:\n\n"; and then PHP crashes, and I
get the Windows XP message asking if I would like to send Microsoft a
bug report. I have several times. Maybe they will respond :-)
 [2002-12-07 14:52 UTC] iliaa@php.net
Can you isolate the function that crashes & with what parameters? So far, I was unable to reproduce the crash using the test servers I have here.
 [2002-12-07 15:09 UTC] chip at cyan dot com
I downgraded the PHP version on this server to 4.2.2
It now works properly on this version.

It crashes on socket_read();

The parameters I am using in my Application are:
socket_read($this->sock[1],2048);

Like I said, the Example Aplication from the PHP Manual for  a WWW Client also crashes, also on socket_read.
 [2002-12-09 09:22 UTC] iliaa@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip


 [2002-12-25 01:00 UTC] 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-05 21:33 UTC] chip at cyan dot com
duplicate of #21197

http://bugs.php.net/bug.php?id=21197
 [2003-02-06 00:25 UTC] magnus@php.net
21197 seems to provide better information. Will mark this 
one as duplicate. 
Please add new comments to: 21197 
 
 [2003-02-06 03:35 UTC] sniper@php.net
There's better report around -> bogus.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Jan 27 12:01:24 2020 UTC