curl / Mailing Lists / curl-library / Single Mail

curl-library

Application gets blocked in libcurl v7.50.2

From: Saurav Babu <saurav.babu_at_samsung.com>
Date: Mon, 06 Mar 2017 10:37:29 +0530

I'm using libcurl v7.50.2. There is an application using libcurl which got blocked
in select() function call in libcurl. When application got terminated then below
backtrace was observed:

(gdb)bt full
#0 0xb5f73414 in select () at /usr/src/debug//////////////glibc-2.20/misc/../sysdeps/unix/syscall-template.S:81
No locals.
#1 0xb643bb5c in Curl_poll (ufds=ufds_at_entry=0xbe4625e8, nfds=nfds_at_entry=1, timeout_ms=timeout_ms_at_entry=-1) at /usr/src/debug/curl-7.50.2/lib/select.c:519
        pending_tv = {tv_sec = 17, tv_usec = -1102699240}
        ptimeout = 0x0
        fds_read = {__fds_bits = {65536, 0 <repeats 31 times>}}
        fds_write = {__fds_bits = {0 <repeats 32 times>}}
        fds_err = {__fds_bits = {0 <repeats 32 times>}}
        maxfd = 16
        initial_tv = {tv_sec = 0, tv_usec = 0}
        fds_none = false
        i = <optimized out>
        pending_ms = 0
        error = <optimized out>
        r = <optimized out>
#2 0xb6444e62 in waitperform (timeout_ms=-1, conn=0x1a8e90) at /usr/src/debug/curl-7.50.2/lib/asyn-ares.c:281
        data = 0xfc3f0
        nfds = <optimized out>
        bitmask = 17
        socks = {16, -1237319519, -1, 0, 0, -1237037511, 16, 1741928, 2, -1102699020, 11, 1891400, 1067992, 374432, -1237037839, -1237343593}
        pfd = {{fd = 16, events = 65, revents = 0}, {fd = 6, events = 0, revents = 0}, {fd = 2, events = -27544, revents = 26}, {fd = 16, events = 65, revents = 0}, {fd = 1740432, events = 0, revents = 0}, {fd = 28, events = 0, revents = 0}, {fd = 0, events = -2752, revents = 35}, {fd = 12, events = -24128, revents = -18875}, {fd = 2, events = -20344, revents = -18959}, {fd = -1236861368, events = -12016, revents = 21}, {fd = 12, events = 19812, revents = 16}, {fd = 8818, events = 8773, revents = 0}, {fd = 8818, events = -8721, revents = 133}, {fd = 1067992, events = 2705, revents = -18880}, {fd = 8818, events = 8773, revents = 0}, {fd = 3, events = 28104, revents = 11}}
        i = <optimized out>
        num = 1
#3 0xb64450d2 in Curl_resolver_wait_resolv (conn=conn_at_entry=0x1a8e90, entry=entry_at_entry=0xbe462744) at /usr/src/debug/curl-7.50.2/lib/asyn-ares.c:387
        tv = {tv_sec = 1033200, tv_usec = 1740432}
        store = {tv_sec = 0, tv_usec = -1000}
        timediff = <optimized out>
        itimeout = -1
        timeout_ms = <optimized out>
        tvp = <optimized out>
        result = CURLE_OK
        data = 0xfc3f0
        timeout = -1
        now = {tv_sec = 8818, tv_usec = 8771}
        temp_entry = 0xb6444fb5 <Curl_resolver_is_resolved+44>
#4 0xb64362e0 in bindlocal (scope=<optimized out>, af=2, sockfd=15, conn=0x1a8e90) at /usr/src/debug/curl-7.50.2/lib/connect.c:359
        ipver = 0
        rc = <optimized out>
        myhost = '\000' <repeats 255 times>
        done = <optimized out>
        is_interface = <optimized out>
        is_host = <optimized out>
        data = 0xfc3f0
        sa = {buffer = {sa = {sa_family = 0, sa_data = '\000' <repeats 13 times>}, sa_in = {sin_family = 0, sin_port = 0, sin_addr = {s_addr = 0}, sin_zero = "\000\000\000\000\000\000\000"}, sa_in6 = {sin6_family = 0, sin6_port = 0, sin6_flowinfo = 0, sin6_addr = {__in6_u = {__u6_addr8 = '\000' <repeats 15 times>, __u6_addr16 = {0, 0, 0, 0, 0, 0, 0, 0}, __u6_addr32 = {0, 0, 0, 0}}}, sin6_scope_id = 0}, sa_stor = {ss_family = 0, __ss_align = 0, __ss_padding = '\000' <repeats 119 times>}}}
        sock = 0xbe46277c
        sizeof_sa = 0
        si6 = 0xbe46277c
        h = 0x0
        si4 = 0xbe46277c
        port = <optimized out>
        portnum = 0
        dev = 0x1cdc48 <error: Cannot access memory at address 0x1cdc48>
        error = <optimized out>
#5 singleipconnect (conn=conn_at_entry=0x1a8e90, ai=<optimized out>, sockp=sockp_at_entry=0x1a9000) at /usr/src/debug/curl-7.50.2/lib/connect.c:1055
        addr = {family = 2, socktype = 1, protocol = 0, addrlen = 16, _sa_ex_u = {addr = {sa_family = 2, sa_data = "\000P6\300\023\203\000\000\000\000\000\000\000"}, buff = {buffer = {sa = {sa_family = 2, sa_data = "\000P6\300\023\203\000\000\000\000\000\000\000"}, sa_in = {sin_family = 2, sin_port = 20480, sin_addr = {s_addr = 2199109686}, sin_zero = "\000\000\000\000\000\000\000"}, sa_in6 = {sin6_family = 2, sin6_port = 20480, sin6_flowinfo = 2199109686, sin6_addr = {__in6_u = {__u6_addr8 = '\000' <repeats 15 times>, __u6_addr16 = {0, 0, 0, 0, 0, 0, 0, 0}, __u6_addr32 = {0, 0, 0, 0}}}, sin6_scope_id = 0}, sa_stor = {ss_family = 2, __ss_align = 2199109686, __ss_padding = '\000' <repeats 105 times>, "C[~\000\000\000\000\330K\020\000\200\362\020"}}}}}
        rc = -1
        error = <optimized out>
        isconnected = false
        data = 0xfc3f0
        sockfd = 15
        result = <optimized out>
        ipaddress = "54.192.19.131", '\000' <repeats 32 times>
        port = 80
        is_tcp = <optimized out>
#6 0xb64367b0 in Curl_connecthost (conn=conn_at_entry=0x1a8e90, remotehost=0x23e5a0) at /usr/src/debug/curl-7.50.2/lib/connect.c:1180
        data = 0xfc3f0
        before = {tv_sec = 8810, tv_usec = 113947}
        result = CURLE_COULDNT_CONNECT
        timeout_ms = <optimized out>
#7 0xb642a8bc in Curl_setup_conn (conn=conn_at_entry=0x1a8e90, protocol_done=0xbe462a53) at /usr/src/debug/curl-7.50.2/lib/url.c:6396
        result = CURLE_OK
        data = 0xfc3f0
#8 0xb643ae0c in Curl_async_resolved (conn=0x1a8e90, protocol_done=protocol_done_at_entry=0xbe462a53) at /usr/src/debug/curl-7.50.2/lib/hostasyn.c:129
        result = <optimized out>
#9 0xb6438dbe in multi_runsingle (multi=multi_at_entry=0x1ce018, now=..., data=data_at_entry=0xfc3f0) at /usr/src/debug/curl-7.50.2/lib/multi.c:1498
        dns = 0x23e5a0
        conn = <optimized out>
        hostname = 0x17cd78 <error: Cannot access memory at address 0x17cd78>
        stream_error = false
        msg = <optimized out>
        connected = true
        async = 15
        protocol_connect = false
        dophase_done = false
        done = false
        rc = CURLM_OK
        result = <optimized out>
        k = <optimized out>
        timeout_ms = <optimized out>
        control = -1102697888
#10 0xb6439766 in curl_multi_perform (multi=0x1ce018, running_handles=running_handles_at_entry=0x5c1b8 <still_running>) at /usr/src/debug/curl-7.50.2/lib/multi.c:2124
        result = <optimized out>
        pipe_st = {old_pipe_act = {__sigaction_handler = {sa_handler = 0xb5fe6000, sa_sigaction = 0xb5fe6000}, sa_mask = {__val = {2, 393048, 3059415588, 3059415464, 0, 3053346816, 3004264328, 48, 3004214464, 1, 3058517583, 638024, 603272, 3004214464, 676128, 0, 3004214464, 436648, 3059111840, 603272, 3059279031, 3004194056, 3004214464, 3004214472, 59, 0, 3059113340, 436648, 0, 1291176, 436648, 1291228}}, sa_flags = -1236451153, sa_restorer = 0x18}, no_signal = true}
        data = 0xfc3f0
        returncode = CURLM_OK
        t = 0xb5fe6000
        now = {tv_sec = 8810, tv_usec = 113253}

On further analysis it is observed that timeout_ms value in waitperform() function is -1. I checked code
and found that if timeout_ms is less that 0 then there is a possibility of timeout argument to be NULL in
select function call. According to man page of select(), it can block indefinitely if timeout argument is
NULL.

Is there any specific reason for timeout_ms to be -1?
Also is there any way so that application is not blocked indefinitely in such situations?

Thanks,
Saurav
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2017-03-06