php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17379 proc_close() causes segmentation fault
Submitted: 2002-05-23 04:14 UTC Modified: 2002-05-23 06:17 UTC
From: kims at contrail dot com dot au Assigned:
Status: Closed Package: Reproducible crash
PHP Version: 4.0CVS-2002-05-23 OS: Debian GNU/Linux
Private report: No CVE-ID: None
 [2002-05-23 04:14 UTC] kims at contrail dot com dot au
proc_close() is causing a segmentation fault in php when I call it with a valid resource (it gives a correct warning if you pass it a null value.

Here's some PHP that causes a segfault for me:

<?
        $ds = array(
                0 => array("pipe", "r"),
                1 => array("pipe", "w"),
                2 => array("file", "/tmp/stderr", "a")
        );

        $cat = proc_open(
                "/bin/cat",
                $ds,
                $pipes
        );

        proc_close($cat);

        echo "I didn't segfault!\n";
?>

And here's a backtrace:

kims@lionred:~/public_html$ gdb /usr/local/bin/php core 
GNU gdb 2002-04-01-cvs
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-linux"...
Core was generated by `php sf.php'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from /lib/libcrypt.so.1...done.
Loaded symbols for /lib/libcrypt.so.1
Reading symbols from /lib/libresolv.so.2...done.
Loaded symbols for /lib/libresolv.so.2
Reading symbols from /lib/libm.so.6...done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libdl.so.2...done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/libpthread.so.0...done.
Loaded symbols for /lib/libpthread.so.0
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
#0  0x081593b2 in zend_fetch_resource (passed_id=0x820aae8, tsrm_ls=0x81d6600, 
    default_id=-1, resource_type_name=0x81937a4 "process", 
    found_resource_type=0x0, num_resource_types=1)
    at /home/kims/php4/Zend/zend_list.c:123
123			} else if ((*passed_id)->type != IS_RESOURCE) {
(gdb) bt
#0  0x081593b2 in zend_fetch_resource (passed_id=0x820aae8, tsrm_ls=0x81d6600, 
    default_id=-1, resource_type_name=0x81937a4 "process", 
    found_resource_type=0x0, num_resource_types=1)
    at /home/kims/php4/Zend/zend_list.c:123
#1  0x080c35c6 in zif_proc_close (ht=1, return_value=0x820f9c8, this_ptr=0x0, 
    return_value_used=0, tsrm_ls=0x81d6600)
    at /home/kims/php4/ext/standard/exec.c:601
#2  0x08167779 in execute (op_array=0x820aa20, tsrm_ls=0x81d6600)
    at /home/kims/php4/Zend/zend_execute.c:1587
#3  0x08152fdf in zend_execute_scripts (type=8, tsrm_ls=0x81d6600, retval=0x0, 
    file_count=3) at /home/kims/php4/Zend/zend.c:810
#4  0x08125dea in php_execute_script (primary_file=0xbffffd48, 
    tsrm_ls=0x81d6600) at /home/kims/php4/main/main.c:1373
#5  0x0817019b in main (argc=2, argv=0xbffffdc4)
    at /home/kims/php4/sapi/cli/php_cli.c:622
(gdb) 

Thankyou.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-23 06:17 UTC] wez@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.

It was my silly mistake: fixed in CVS now - thanks for reporting it!
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sat Dec 13 09:00:01 2025 UTC