|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21529 Segmentation fault in command line script execution
Submitted: 2003-01-08 15:44 UTC Modified: 2003-01-08 21:34 UTC
From: francesco dot laurita at fastweb dot it Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 4.3.0 OS: Linux RedHat 7.3 2.4.18
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
45 + 34 = ?
Subscribe to this entry?

 [2003-01-08 15:44 UTC] francesco dot laurita at fastweb dot it
Script that cause crash:
This script load hosts from file and try to connect with them
        $list = file('host.txt');

        for ($i = 0; $i<count($list);$i++){
                $data = explode(":",trim($list[$i]));
                echo "Try ".$data[0]." on port ".$data[1]."\n";
                $sock = fsockopen($data[0],$data[1],&$errno,&$errstr,10);

                if ($sock){
                        echo "Connected on ".trim($list[$i])."\n";
                        exec("echo ".trim($list[$i])." >> pro.log");



Configure line:
 ./configure --enable-ftp --with-gd --with-zlib --enable-calendar --enable-trans-sid --enable-xslt=/usr/lib --with-apxs=/usr/local/apache/bin/apxs --enable-sigchild --with-xml --with-expat=/usr/lib --with-xslt-sablot=/usr/lib --with-mysql=/usr --enable-pcntl --without-pear

Default setting excepted the include_path

(gdb) bt
#0  0x08114a32 in php_sockop_close (stream=0x81f316c, close_handle=1) at /usr/src/redhat/SOURCES/php-4.3.0/main/network.c:996
#1  0x081111d1 in _php_stream_free (stream=0x81f316c, close_options=3) at /usr/src/redhat/SOURCES/php-4.3.0/main/streams.c:327
#2  0x080ad98b in zif_fclose (ht=1, return_value=0x81f30fc, this_ptr=0x0, return_value_used=0)
    at /usr/src/redhat/SOURCES/php-4.3.0/ext/standard/file.c:1120
#3  0x08141bd4 in execute (op_array=0x81f0a44) at /usr/src/redhat/SOURCES/php-4.3.0/Zend/zend_execute.c:1596
#4  0x0812f7e4 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /usr/src/redhat/SOURCES/php-4.3.0/Zend/zend.c:864
#5  0x081096ed in php_execute_script (primary_file=0xbffffa30) at /usr/src/redhat/SOURCES/php-4.3.0/main/main.c:1573
#6  0x0814b12c in main (argc=3, argv=0xbffffad4) at /usr/src/redhat/SOURCES/php-4.3.0/sapi/cli/php_cli.c:746
#7  0x42017589 in __libc_start_main () from /lib/i686/
(gdb) frame 3
#3  0x08141bd4 in execute (op_array=0x81f0a44) at /usr/src/redhat/SOURCES/php-4.3.0/Zend/zend_execute.c:1596
1596                                                            ((zend_internal_function *) EX(function_state).function)->handler(EX(opline)->extended_value, EX(Ts)[EX(opline)->result.u.var].var.ptr, EX(object).ptr, return_value_used TSRMLS_CC);

This is a only command line script
I've try to recompile whith --enable-debug but in this case i have not crash.
The host in the host file are 541.
Output example:
[fra@ebmserver fra]# php -q script.php 
Try on port 80
Connected on
Try xxx.5xx.xx.2xx on port 80
Connected on 1xx.xx.xx.xx:80
Try xx.kxxi.xx on port 80
Connected on
Try on port 80

Warning: fsockopen() []: php_network_getaddresses: getaddrinfo failed: Name or service not known in /fra/script.php on line 7

Warning: fsockopen() []: unable to connect to xxx.xxxau.xx:80 in /fra/script.php on line 7
Try 13xx.2xx8.xx1.xx on port 8080

Warning: fsockopen() []: php_hostconnect: connect failed in /fra/script.php on line 7

Warning: fsockopen() []: unable to connect to in /fra/script.php on line 7
Try wesxxxu.xx.texxxa.xx on port 80
Connected on
Try on port 80
Connected on
Try nxxx2.rxxxa.cxxa on port 80
Connected on
Segmentation fault (core dumped)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-08 21:33 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 17 22:01:28 2024 UTC