php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33222 segmentation fault when trying to run curl_close from the handler function
Submitted: 2005-06-02 16:55 UTC Modified: 2005-06-02 23:06 UTC
From: public at grik dot net Assigned: tony2001
Status: Closed Package: cURL related
PHP Version: 5.*, 4.* OS: *
Private report: No CVE-ID:
 [2005-06-02 16:55 UTC] public at grik dot net
Description:
------------
When I try to close CURL connection from the function, registered as a handler for the output (header or body), PHP crashes.

Reproduce code:
---------------
<?php

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "http://www.yahoo.com/");

curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'header_callback');

curl_exec($ch);

curl_close($ch);

function header_callback($ch, $string){
    echo $string;
    curl_close($ch);
    return strlen($string);
}

?>

Expected result:
----------------
HTTP/1.1 200 OK

Actual result:
--------------
HTTP/1.1 200 OK
Segmentation fault


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-02 17:17 UTC] public at grik dot net
backtrace:
(gdb) bt
#0  0x403a9d84 in Curl_readwrite (conn=0x81f584c, done=0xbfffc39f "")
    at transfer.c:890
#1  0x403aaf56 in Transfer (conn=0x81f584c) at transfer.c:1480
#2  0x403ab94a in Curl_perform (data=0x81f7b7c) at transfer.c:1985
#3  0x403ac175 in curl_easy_perform (curl=0x81f7b7c) at easy.c:378
#4  0x4002c3d2 in zif_curl_exec (ht=1, return_value=0x81f55dc, this_ptr=0x0,
    return_value_used=0)
    at /usr/src/web/php5-STABLE-200505161036/ext/curl/interface.c:1261
#5  0x0814a267 in zend_do_fcall_common_helper (execute_data=0xbfffc610,
    opline=0x81f5068, op_array=0x81f09a4)
    at /usr/src/web/php5-STABLE-200505161036/Zend/zend_execute.c:2747
#6  0x0814a8c8 in zend_do_fcall_handler (execute_data=0xbfffc610,
    opline=0x81f5068, op_array=0x81f09a4)
    at /usr/src/web/php5-STABLE-200505161036/Zend/zend_execute.c:2881
#7  0x08147188 in execute (op_array=0x81f09a4)
    at /usr/src/web/php5-STABLE-200505161036/Zend/zend_execute.c:1417
#8  0x081239fe in zend_execute_scripts (type=8, retval=0x0, file_count=3)
    at /usr/src/web/php5-STABLE-200505161036/Zend/zend.c:1080
#9  0x080e5323 in php_execute_script (primary_file=0xbfffe9e0)
    at /usr/src/web/php5-STABLE-200505161036/main/main.c:1646
#10 0x08153187 in main (argc=4, argv=0xbfffea84)
    at /usr/src/web/php5-STABLE-200505161036/sapi/cgi/cgi_main.c:1582
#11 0x42015574 in __libc_start_main () from /lib/tls/libc.so.6
 [2005-06-02 17:20 UTC] public at grik dot net
Program received signal SIGSEGV, Segmentation fault.
0x403a9d84 in Curl_readwrite (conn=0x81f584c, done=0xbfffc39f "")
    at transfer.c:890
890               }
 [2005-06-02 18:07 UTC] tony2001@php.net
What is the version of cURL used? 
What if you try to upgrade it to the latest available from http://curl.haxx.se/download.html ?
 [2005-06-02 18:40 UTC] public at grik dot net
CURL Information 	libcurl/7.12.0 

it's not old, I upgraded it not so long ago, and manual says PHP5 requires 7.10.5

trying to upgrade to CURL 7.14
 [2005-06-02 19:10 UTC] public at grik dot net
Segmentation fault persists

curl_version():
Array
(
    [version_number] => 462336
    [age] => 2
    [features] => 540
    [ssl_version_number] => 0
    [version] => 7.14.0
    [host] => i686-pc-linux-gnu
    [ssl_version] =>  OpenSSL/0.9.7a
    [libz_version] => 1.1.4
    [protocols] => Array
        (
            [0] => ftp
            [1] => gopher
            [2] => telnet
            [3] => dict
            [4] => ldap
            [5] => http
            [6] => file
            [7] => https
            [8] => ftps
        )
)
 [2005-06-02 21:44 UTC] tony2001@php.net
Assigned to myself. Patch pending.
 [2005-06-02 23:06 UTC] tony2001@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Fri Apr 18 13:02:15 2014 UTC