From:             [EMAIL PROTECTED]
Operating system: mandrake 8.2, 2.4.18-8.1mdk
PHP version:      4.3.0
PHP Bug Type:     Reproducible crash
Bug description:  fsockopen() crashes on 2 of 3 servers (w/ gdb trace)

Compiling 4.3.0 and php4-STABLE-200301222030 on 3 servers, one works and
two segfault.  The simple script below illustrates the problem; on one
server it runs, on two it faults.  The three servers are essentially
identical; php.ini on all are identical.

Build details and gdb backtrace are below.  I also have fopen("http://";)
failing the same way, not surprising.  The failure appears to be in DNS
resolution.  Glad to supply more info as needed.

<?php
$fd = fsockopen("www.yahoo.com", 80, &$errno, &$errstr);
if( !$fd ) {
    echo "yahoo not available";
    exit();
} else {
    fputs($fd,"GET / HTTP/1.0\r\n\r\n");
    fputs($fd,"Host: $host\r\n\r\n");
    while (!feof($fd)) {
        echo fread($fd,16000);
    }
    fclose($fd);
}
?>

=================================================

php was built with the following options:

./configure \
 --with-gd \
 --with-mysql=/usr \
 --with-exec-dir=/var/lib/php \
 --with-java=/usr/local/jdk \
 --enable-unified-odbc \
 --enable-safe-mode=yes \
 --enable-track-vars \
 --enable-ftp \
 --with-expat-dir=/usr \
 --with-xml \
 --with-dom=/usr \
 --with-dom-xslt=/usr \
 --with-dom-exslt=/usr \
 --enable-xslt \
 --with-xslt-sablot=/usr \
 --with-sablot-js=/usr \
 --with-zlib \
 --with-ldap \
 --with-openssl \
 --disable-debug \
 --disable-debugger \
 --with-config-file-path=/etc/httpd/conf

The bind version on all servers is 8.3.3, patched with ISC patches prior
to 8.3.4 release from recent bugs.

=================================================

gdb run commands:

gdb stacktrace:(gdb) set args fsock_yahoo.php
(gdb) run
Starting program: /usr/local/bin/php fsock_yahoo.php
[New Thread 1024 (LWP 3639)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 3639)]
0x081335d5 in php_network_getaddresses (host=0x831c59c "www.yahoo.com", 
    sal=0xbfffc634) at /usr/local/php4/main/network.c:215
215                                     *(struct sockaddr_in *)*sap =


#0  0x081335d5 in php_network_getaddresses (host=0x831c59c
"www.yahoo.com", 
    sal=0xbfffc634) at /usr/local/php4/main/network.c:215
#1  0x08133810 in php_hostconnect (host=0x831c59c "www.yahoo.com",
port=80, 
    socktype=1, timeout=0xbfffc6b0) at /usr/local/php4/main/network.c:410
#2  0x08133b5f in _php_stream_sock_open_host (host=0x831c59c
"www.yahoo.com", 
    port=80, socktype=1, timeout=0xbfffc6b0, persistent_id=0x0)
    at /usr/local/php4/main/network.c:619
#3  0x080ee025 in php_fsockopen_stream (ht=4, return_value=0x831c5dc, 
    this_ptr=0x0, return_value_used=1, persistent=0)
    at /usr/local/php4/ext/standard/fsock.c:218
#4  0x080ee1ed in zif_fsockopen (ht=4, return_value=0x831c5dc,
this_ptr=0x0, 
    return_value_used=1) at /usr/local/php4/ext/standard/fsock.c:278
#5  0x0815d2d2 in execute (op_array=0x8322504)
    at /usr/local/php4/Zend/zend_execute.c:1596
#6  0x0814cdf3 in zend_execute_scripts (type=8, retval=0x0, file_count=3)
    at /usr/local/php4/Zend/zend.c:864
#7  0x0812992b in php_execute_script (primary_file=0xbffff560)
    at /usr/local/php4/main/main.c:1573
#8  0x08164488 in main (argc=2, argv=0xbffff604)
    at /usr/local/php4/sapi/cli/php_cli.c:746
#9  0x405be280 in __libc_start_main () from /lib/libc.so.6

-- 
Edit bug report at http://bugs.php.net/?id=21829&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=21829&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=21829&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=21829&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=21829&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=21829&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=21829&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=21829&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=21829&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=21829&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=21829&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=21829&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=21829&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=21829&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=21829&r=gnused

Reply via email to