cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: multithread curl. unexpected SIGSEGV

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 17 Sep 2012 14:58:42 +0200 (CEST)

On Mon, 17 Sep 2012, Azat Khuzhin wrote:

> 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:

You shouldn't post "all program sources" - because we don't want them. You
should write a new stand-alone example that repeats your problem and then post
_that_ source code.

If you can reproduce the problem in a separate application, chances are the
problem is in your code.

> 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)

... this has nothing to do with libcurl but rather shows a problem in your
application.

> 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)

This could just as well be a thread/synch problem in your application. If you
look at the curl_slist_free_all() implementation you'll see that it doesn't
have a lot of logic that can go wrong.

> Also valgrind show that Curl_ssl_connect is called (how ? If I allow only
> HTTP protocol)

That seems strange yes and I can't explain it. Can't you just set a
break-point and see how it gets there?

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