|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42420 Segmentation fault when using FTP proxy
Submitted: 2007-08-25 02:51 UTC Modified: 2008-07-21 01:00 UTC
From: mkwan at darkside dot com dot au Assigned: pollita (profile)
Status: No Feedback Package: Reproducible crash
PHP Version: 5.2CVS-2007-09-04 OS: *
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 — but make sure to vote on the bug!
Your email address:
Solve the problem:
4 + 26 = ?
Subscribe to this entry?

 [2007-08-25 02:51 UTC] mkwan at darkside dot com dot au
Calling the file_get_contents() function with the ftp:// wrapper causes a segmentation fault when an FTP proxy is enabled with the stream_context_get_default function.

The machine is running Fedora 7 with an Apache server which has proxying enabled.

Just for comparison, the following command DOES work -

export ftp_proxy=localhost:8080

Reproduce code:
    stream_context_get_default (
        array ("ftp" => array ("proxy" => "tcp://localhost:8080"))

    $gif = file_get_contents ("");
    if ($gif === false)
        echo "failed\n";
        echo "size = " . strlen ($gif) . "\n";

Expected result:
I expect to see a message of the form "size = 22544"

Actual result:
Segmentation fault


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2007-08-26 16:48 UTC]
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read for *NIX and for Win32

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.

 [2007-08-26 23:47 UTC] mkwan at darkside dot com dot au
#0  0x081ce50c in ?? ()
#1  0x08191a7e in ?? ()
#2  0x081ce9d4 in _php_stream_free ()
#3  0x081533fa in zif_file_get_contents ()
#4  0x08233b00 in ?? ()
#5  0x08223048 in execute ()
#6  0x0820241a in zend_execute_scripts ()
#7  0x081bc256 in php_execute_script ()
#8  0x082885ab in main ()
 [2007-08-27 09:21 UTC]
And now read again the above mentioned page and reconfigure your PHP isntallation using --enable-debug this time. Also, use the latest 5.2 CVS snapshot from:

 [2007-09-04 10:38 UTC] mkwan at darkside dot com dot au
Sorry, but I'm using an RPM installation, and I'm not in a position to compile/install/test/remove a debugging version of PHP just so I can submit a bug report.
I don't think a developer would have any trouble reproducing it.
One other piece of diagnostic information that may be useful: the following line appears in the Apache log - - - [23/Aug/2007:14:17:43 +1000] "GET HTTP/1.0" 200 22489 "-" "-"
So it looks like PHP crashes *after* connecting to the proxy and requesting the file.
 [2007-09-04 10:58 UTC]
Here's a backtrace I got with latest 5.2 CVS:

Program received signal SIGSEGV, Segmentation fault.
0x082a8b13 in _php_stream_write_filtered (stream=0xa1f84a4, buf=0x857550f "QUIT\r\n", count=6, flags=0)
    at /home/jani/src/php-5.2/main/streams/streams.c:955
955                     status = filter->fops->filter(stream, filter, brig_inp, brig_outp,
(gdb) bt
#0  0x082a8b13 in _php_stream_write_filtered (stream=0xa1f84a4, buf=0x857550f "QUIT\r\n", count=6, flags=0)
    at /home/jani/src/php-5.2/main/streams/streams.c:955
#1  0x082a8cb7 in _php_stream_write (stream=0xa1f84a4, buf=0x857550f "QUIT\r\n", count=6) at /home/jani/src/php-5.2/main/streams/streams.c:1021
#2  0x08266db6 in php_stream_ftp_stream_close (wrapper=0x85ccea8, stream=0xa1f88e8) at /home/jani/src/php-5.2/ext/standard/ftp_fopen_wrapper.c:102
#3  0x082a77e2 in _php_stream_free (stream=0xa1f88e8, close_options=3) at /home/jani/src/php-5.2/main/streams/streams.c:366
#4  0x0821203f in zif_file_get_contents (ht=1, return_value=0xa1f7318, return_value_ptr=0x0, this_ptr=0x0, return_value_used=1)
    at /home/jani/src/php-5.2/ext/standard/file.c:577
#5  0x0830ad90 in zend_do_fcall_common_helper_SPEC (execute_data=0xbfec8b04) at /home/jani/src/php-5.2/Zend/zend_vm_execute.h:200
#6  0x0831064d in ZEND_DO_FCALL_SPEC_CONST_HANDLER (execute_data=0xbfec8b04) at /home/jani/src/php-5.2/Zend/zend_vm_execute.h:1681
#7  0x0830a8f1 in execute (op_array=0xa1f7ab0) at /home/jani/src/php-5.2/Zend/zend_vm_execute.h:92
#8  0x082e5ba3 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /home/jani/src/php-5.2/Zend/zend.c:1134
#9  0x082929af in php_execute_script (primary_file=0xbfecaea0) at /home/jani/src/php-5.2/main/main.c:1986
#10 0x0835f9a0 in main (argc=3, argv=0xbfecaff4) at /home/jani/src/php-5.2/sapi/cli/php_cli.c:1140

 [2007-09-04 12:31 UTC]
Assigned to the maintainer of the FTP stuff. 
Sara: Seems like there's some issues with filters. 
Propably not related but I stumbled to this:


    for(current = filter; current; current = current->next) {

current isn't used anyplace else there..

Also it seems that the filters are nuked in _php_stream_free() before the closer is run..

 [2008-07-21 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, 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".
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Fri Aug 19 02:03:36 2022 UTC