|  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 (profile)
Status: Closed Package: cURL related
PHP Version: 5.*, 4.* OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: public at grik dot net
New email:
PHP Version: OS:


 [2005-06-02 16:55 UTC] public at grik dot net
When I try to close CURL connection from the function, registered as a handler for the output (header or body), PHP crashes.

Reproduce code:

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "");

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



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


Expected result:
HTTP/1.1 200 OK

Actual result:
HTTP/1.1 200 OK
Segmentation fault


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-06-02 17:17 UTC] public at grik dot net
(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,
    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/
 [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]
What is the version of cURL used? 
What if you try to upgrade it to the latest available from ?
 [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

    [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]
Assigned to myself. Patch pending.
 [2005-06-02 23:06 UTC]
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
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Jan 26 00:01:25 2020 UTC