cURL / Mailing Lists / curl-library / Single Mail

curl-library

Segmentation Fault while doing curl_easy_perform...

From: Chiaramello Daniel <Daniel.Chiaramello_at_gemalto.com>
Date: Tue, 15 Oct 2013 16:30:56 +0200

Hello curl gurus.

I am facing a problem while sending an HTTPS request with curl...

Here is an extract of the code, all error code being removed, and curl_global_init() and curl_global_cleanup() being called in main:

bool FB_call_webservice(const char* AA_param)
{
  string VH_json_string = FH_format(
      "{\"param\":\"%s\"}",
       AA_param);

  CURL* VH_curl;
  struct curl_slist* VH_headerlist;
  CURLcode VI_res;
  long VI_http_code;

  VH_curl = curl_easy_init();

  VH_headerlist = curl_slist_append(NULL, "Content-Type: application/json; charset=utf-8");
  VI_res = curl_easy_setopt(VH_curl, CURLOPT_HTTPHEADER, VH_headerlist);

  VI_res = curl_easy_setopt(VH_curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
  VI_res = curl_easy_setopt(VH_curl, CURLOPT_NOSIGNAL, true);
  VI_res = curl_easy_setopt(VH_curl, CURLOPT_CONNECTTIMEOUT, 5);
  VI_res = curl_easy_setopt(VH_curl, CURLOPT_FOLLOWLOCATION, true);
  VI_res = curl_easy_setopt(VH_curl, CURLOPT_SSL_VERIFYHOST, false);
  VI_res = curl_easy_setopt(VH_curl, CURLOPT_URL, GH_url.c_str());
  VI_res = curl_easy_setopt(VH_curl, CURLOPT_POSTFIELDS, VH_json_string.c_str());
  VI_res = curl_easy_setopt(VH_curl, CURLOPT_POSTFIELDSIZE, VH_json_string.size());

  VI_res = curl_easy_perform(VH_curl);
  VI_res = curl_easy_getinfo(VH_curl, CURLINFO_RESPONSE_CODE, &VI_http_code);

  curl_slist_free_all(VH_headerlist);
  curl_easy_cleanup(VH_curl);

  return (VI_http_code == 200);
}

I have the following crash systematically while calling curl_easy_perform:

Program terminated with signal 11, Segmentation fault.
[New process 13954]
#0 0x0945fb80 in ?? ()
(gdb) where
#0 0x0945fb80 in ?? ()
#1 0x010cf808 in EVP_CIPHER_CTX_cleanup () from /lib/libcrypto.so.6
#2 0x010cfa48 in EVP_CipherInit_ex () from /lib/libcrypto.so.6
#3 0x004716b4 in tls1_change_cipher_state () from /lib/libssl.so.6
#4 0x00468662 in ssl3_connect () from /lib/libssl.so.6
#5 0x0047acba in SSL_connect () from /lib/libssl.so.6
#6 0x0046f4e1 in ssl23_connect () from /lib/libssl.so.6
#7 0x0047acba in SSL_connect () from /lib/libssl.so.6
#8 0x00293dc2 in ?? () from /usr/lib/libcurl.so.3
#9 0x0029485d in Curl_ossl_connect () from /usr/lib/libcurl.so.3
#10 0x002a433f in Curl_ssl_connect () from /usr/lib/libcurl.so.3
#11 0x00283af2 in Curl_http_connect () from /usr/lib/libcurl.so.3
#12 0x0028c181 in Curl_protocol_connect () from /usr/lib/libcurl.so.3
#13 0x0028e940 in Curl_connect () from /usr/lib/libcurl.so.3
#14 0x0029944b in ?? () from /usr/lib/libcurl.so.3
#15 0x0029ba40 in Curl_perform () from /usr/lib/libcurl.so.3
#16 0x0029bfc9 in curl_easy_perform () from /usr/lib/libcurl.so.3
#17 0x0027296c in FB_call_webservice (AA_param=0x9aa5554 "234010000000000") at send_webservice.cpp:388
#18 0x00b1a9f9 in FB_handle_trigger (APS_msg=0x9aa5550) at send_trigger_queue.cpp:55
#19 0x00b1ac43 in FV_handle_queue_thread (AP_data=0x1) at send_trigger_queue.cpp:112
#20 0x007da49b in start_thread () from /lib/libpthread.so.0
#21 0x005c942e in clone () from /lib/libc.so.6

The versions installed are:
> rpm -qa | grep openssl
openssl-0.9.8e-20.el5
> rpm -qa | grep curl
curl-7.15.5-9.el5_6.3

I don't understand what's happening. It works correctly when the URL specified is http, but it crashes in https. Certificate is correctly installed, the https target server is successfully reached when calling it through the curl command-line tool, but it crashes in my application... Did I miss something? Is it a known bug in these versions?

Thanks for your attention,
Daniel

________________________________
This message and any attachments are intended solely for the addressees and may contain confidential information. Any unauthorized use or disclosure, either whole or partial, is prohibited.
E-mails are susceptible to alteration. Our company shall not be liable for the message if altered, changed or falsified. If you are not the intended recipient of this message, please delete it and notify the sender.
Although all reasonable efforts have been made to keep this transmission free from viruses, the sender will not be liable for damages caused by a transmitted virus

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2013-10-15