cURL / Mailing Lists / curl-library / Single Mail

curl-library

multithread curl. unexpected SIGSEGV

From: Azat Khuzhin <dohardgopro_at_gmail.com>
Date: Mon, 17 Sep 2012 15:00:39 +0400

Hi all,

I have SIGSEGV when I run curl in 400 threads.
valgrind doesn't detect any memory errors.

I can't post here all program sources, but here is some info:

I setup curl (via curl_easy_setopt) for multithread environment:
  // CURL *handle ch;
  curl_easy_setopt(ch, CURLOPT_NOSIGNAL, 1L);
  curl_easy_setopt(ch, CURLOPT_DNS_USE_GLOBAL_CACHE, 0L);
  curl_easy_setopt(ch, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTP);
  curl_easy_setopt(ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTP);

At all time program runs, only one valgrind message (valgrind
--show-reachable=yes --leak-check=full) :
==30908== Thread 3:
==30908== Conditional jump or move depends on uninitialised value(s)
==30908== at 0x4C2B837: __GI___rawmemchr (mc_replace_strmem.c:1110)
==30908== by 0x532A2AF: _IO_str_init_static_internal (strops.c:45)
==30908== by 0x531E9D4: vsscanf (iovsscanf.c:44)
==30908== by 0x530AB97: sscanf (sscanf.c:34)
==30908== by 0x4074E9: parseUrl (crawler.c:28)
==30908== by 0x407961: startRoutine (crawler.c:125)
==30908== by 0x4E35B4F: start_thread (pthread_create.c:304)
==30908== by 0x538D70C: clone (clone.S:112)
==30908==

And it caught SIGSEGV:
==30908== Process terminating with default action of signal 11 (SIGSEGV)
==30908== General Protection Fault
==30908== at 0x50926C8: curl_slist_free_all (in
/usr/lib/x86_64-linux-gnu/libcurl.so.4.2.0)
==30908== by 0x4031AF: curlSetOptionPC (curl.c:138)
==30908== by 0x407CB2: startRoutine (crawler.c:185)
==30908== by 0x4E35B4F: start_thread (pthread_create.c:304)
==30908== by 0x538D70C: clone (clone.S:112)

At curl.c:138:
// struct curl_slist httpCustomHeader;
curl_slist_free_all(httpCustomHeader);

Also valgrind show that Curl_ssl_connect is called (how ? If I allow
only HTTP protocol)
==30908== 211,800 bytes in 353 blocks are still reachable in loss
record 153 of 175
==30908== at 0x4C28BED: malloc (vg_replace_malloc.c:263)
==30908== by 0x6826B83: CRYPTO_malloc (in
/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==30908== by 0x68A44F5: ERR_get_state (in
/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==30908== by 0x68A499E: ERR_put_error (in
/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.0)
==30908== by 0x6588A98: SSL_CTX_new (in
/usr/lib/x86_64-linux-gnu/libssl.so.1.0.0)
==30908== by 0x50734BE: ossl_connect_common (in
/usr/lib/x86_64-linux-gnu/libcurl.so.4.2.0)
==30908== by 0x50749F4: Curl_ossl_connect (in
/usr/lib/x86_64-linux-gnu/libcurl.so.4.2.0)
==30908== by 0x5089016: Curl_ssl_connect (in
/usr/lib/x86_64-linux-gnu/libcurl.so.4.2.0)
==30908== by 0x505D894: Curl_http_connect (in
/usr/lib/x86_64-linux-gnu/libcurl.so.4.2.0)
==30908== by 0x506FB13: Curl_protocol_connect (in
/usr/lib/x86_64-linux-gnu/libcurl.so.4.2.0)
==30908== by 0x506FDE9: Curl_setup_conn (in
/usr/lib/x86_64-linux-gnu/libcurl.so.4.2.0)
==30908== by 0x506FE93: Curl_connect (in
/usr/lib/x86_64-linux-gnu/libcurl.so.4.2.0)

$ curl -V
curl 7.26.0 (x86_64-pc-linux-gnu) libcurl/7.26.0 OpenSSL/1.0.1c
zlib/1.2.7 c-ares/1.9.1 libidn/1.25 libssh2/1.4.2 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3
pop3s rtmp rtsp scp sftp smtp smtps telnet tftp
Features: AsynchDNS Debug GSS-Negotiate IDN IPv6 Largefile NTLM
NTLM_WB SSL libz TLS-SRP
$ uname -r
3.0.0-1-amd64

-- 
Azat Khuzhin
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2012-09-17