curl / Mailing Lists / curl-library / Single Mail

curl-library

crash in Curl_ssl_connect_nonblocking

From: Gangadhar Hariharan <gangadhar.hariharan_at_gmail.com>
Date: Fri, 23 Mar 2018 22:34:01 -0700

Hi curl users,

I am using 2 threads. One for adding curl handle to multi-handle and the
other to execute the multi_perform. i have a recursive mutex to safeguard
the adding/executing of the multi-handle.
In one of the executions, i see a crash in curl_multi_perform() with a
stack frame at Curl_ssl_connect_nonblocking. i have never seen this before
and i have been running my applications successfully for over 4 months.
Any inputs will be appreciated

thread1:

take_recursive_mutex_lock(r_mx);
curl_multi_add_handle(mh, eh);
release_recursive_lock(r_mx);
------------

thread2:

take_recursive_mutex_lock(r_mx);
mret = curl_multi_perform(mh, &still_running);
release_recursive_lock(r_mx);
-----------

It is observed that, thread1 is waiting on thread2 to release the lock and
in thread2, there is a crash in curl_multi_perform():
I see a frame at Curl_ssl_connect_nonblocking. Not sure why this would
crash!

(gdb) thread 2
[Switching to thread 2 (Thread 0xb14c1440 (LWP 7180))]
#0 0x1004e1fc in pal_sigsegv ()
(gdb) bt
#0 0x1004e1fc in pal_sigsegv ()
#1 <signal handler called>
#2 _asn1_copy_structure3 (source_node=source_node_at_entry=0x119ae3e8)
    at
/work/mysrc/debug/gnutls/3.4.9-r0/gnutls-3.4.9/lib/minitasn1/structure.c:426
#3 0x0f62f6d4 in _asn1_append_sequence_set (node=<optimized out>,
    ptail=ptail_at_entry=0xb14c0850)
    at
/work/mysrc/debug/gnutls/3.4.9-r0/gnutls-3.4.9/lib/minitasn1/element.c:155
#4 0x0f62aaac in asn1_der_decoding2 (element=element_at_entry=0x10c11f58,
    ider=0x119af648, max_ider_len=max_ider_len_at_entry=0xb14c08f8,
    flags=flags_at_entry=2, errorDescription=errorDescription_at_entry=0x0)
    at
/work/mysrc/debug/gnutls/3.4.9-r0/gnutls-3.4.9/lib/minitasn1/decoding.c:1440
#5 0x0f5d8804 in _asn1_strict_der_decode (errorDescription=0x0, len=1359,
    ider=<optimized out>, element=0x10c11f58)
    at /work/mysrc/debug/gnutls/3.4.9-r0/gnutls-3.4.9/lib/x509/common.h:252
#6 gnutls_x509_crt_import (cert=0x10c11f58, data=data_at_entry=0xb14c0978,
    format=format_at_entry=GNUTLS_X509_FMT_PEM)
    at /work/mysrc/debug/gnutls/3.4.9-r0/gnutls-3.4.9/lib/x509/x509.c:310
#7 0x0f5dd160 in gnutls_x509_crt_list_import (certs=0x5d518710,
    cert_max=cert_max_at_entry=0xb14c09d8, data=data_at_entry=0xb14c0a60,
    format=format_at_entry=GNUTLS_X509_FMT_PEM, flags=flags_at_entry=1)
    at /work/mysrc/debug/gnutls/3.4.9-r0/gnutls-3.4.9/lib/x509/x509.c:3365
#8 0x0f5dd4c4 in gnutls_x509_crt_list_import2 (certs=certs_at_entry
=0xb14c0a24,
    size=size_at_entry=0xb14c0a1c, data=data_at_entry=0xb14c0a60,
    format=format_at_entry=GNUTLS_X509_FMT_PEM, flags=flags_at_entry=0)
    at /work/mysrc/debug/gnutls/3.4.9-r0/gnutls-3.4.9/lib/x509/x509.c:3244
#9 0x0f5e51ec in gnutls_x509_trust_list_add_trust_mem (
    list=list_at_entry=0x5d517af8, cas=cas_at_entry=0xb14c0a60,
    crls=crls_at_entry=0xb14c0a58, type=type_at_entry=GNUTLS_X509_FMT_PEM,
    tl_flags=tl_flags_at_entry=2, tl_vflags=tl_vflags_at_entry=0)
    at
/work/mysrc/debug/gnutls/3.4.9-r0/gnutls-3.4.9/lib/x509/verify-high2.c:80
#10 0x0f5e55d0 in gnutls_x509_trust_list_add_trust_file (list=0x5d517af8,
    ca_file=<optimized out>, crl_file=crl_file_at_entry=0x0,
    type=type_at_entry=GNUTLS_X509_FMT_PEM, tl_flags=tl_flags_at_entry=2,
    tl_vflags=tl_vflags_at_entry=0)
    at
/work/mysrc/debug/gnutls/3.4.9-r0/gnutls-3.4.9/lib/x509/verify-high2.c:362
#11 0x0f5976fc in gnutls_certificate_set_x509_trust_file (
    cred=<optimized out>, cafile=<optimized out>,
    type=type_at_entry=GNUTLS_X509_FMT_PEM)
    at /work/mysrc/debug/gnutls/3.4.9-r0/gnutls-3.4.9/lib/gnutls_x509.c:1611
#12 0x0fbe7758 in gtls_connect_step1 (sockindex=0, conn=0x5cccc500)
    at /work/mysrc/debug/curl/7.47.1-r0/curl-7.47.1/lib/vtls/gtls.c:458
#13 gtls_connect_common (conn=0x5cccc500, sockindex=0,
    nonblocking=<optimized out>, done=0xb14c0b92)
    at /work/mysrc/debug/curl/7.47.1-r0/curl-7.47.1/lib/vtls/gtls.c:1321
#14 0x0fbe8b80 in Curl_ssl_connect_nonblocking (conn=conn_at_entry=0x5cccc500,
    sockindex=sockindex_at_entry=0, done=done_at_entry=0xb14c0b92)
    at /work/mysrc/debug/curl/7.47.1-r0/curl-7.47.1/lib/vtls/vtls.c:333
#15 0x0fbb2460 in https_connecting (done=0xb14c0b92, conn=0x5cccc500)
    at /work/mysrc/debug/curl/7.47.1-r0/curl-7.47.1/lib/http.c:1386
#16 Curl_http_connect (conn=0x5cccc500, done=0xb14c0b92)
    at /work/mysrc/debug/curl/7.47.1-r0/curl-7.47.1/lib/http.c:1356
#17 0x0fbc4890 in Curl_protocol_connect (conn=0x5cccc500,
    protocol_done=protocol_done_at_entry=0xb14c0b92)
    at /work/mysrc/debug/curl/7.47.1-r0/curl-7.47.1/lib/url.c:3668
#18 0x0fbd5f48 in multi_runsingle (multi=0x106156e8, multi_at_entry=0x0,
    now=<error reading variable: value has been optimized out>,
    data=data_at_entry=0x119fc760)
    at /work/mysrc/debug/curl/7.47.1-r0/curl-7.47.1/lib/multi.c:1264
#19 0x0fbd6b50 in curl_multi_perform (multi_handle=0x0, running_handles=0x0)
    at /work/mysrc/debug/curl/7.47.1-r0/curl-7.47.1/lib/multi.c:1821
#20 0x10041604 in my_thread ()
#21 0x0ffc3ec0 in start_my_thread (arg=0xb14c1440)
    at /work/mysrc/debug/glibc/2.23-r0/git/nptl/pthread_create.c:335
#22 0x0f7936c4 in clone () from /lib/libc.so.6
(gdb)​​

​Thanks,
-Gangadhar​

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2018-03-24