cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Bug in libcurl in multithreaded program

From: Avery Fay <avery_fay_at_symantec.com>
Date: Fri, 24 May 2002 09:36:20 -0400

I compiled libcurl and my program with -O0 (for no optimization). Here are
the new traces.

With 16 threads:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 15376 (LWP 726)]
0x4004bb92 in Curl_hash_clean_with_criterium (h=0x8170e10, user=0xbdbff7ec,
    comp=0x4002fae8 <_curl_hostcache_timestamp_remove>) at hash.c:267
267 le = CURL_LLIST_HEAD(h->table[i]);
(gdb) bt
#0 0x4004bb92 in Curl_hash_clean_with_criterium (h=0x8170e10,
    user=0xbdbff7ec, comp=0x4002fae8 <_curl_hostcache_timestamp_remove>)
    at hash.c:267
#1 0x4002fb5c in hostcache_prune (hostcache=0x8170e10, cache_timeout=60,
    now=1022247113) at hostip.c:182
#2 0x4002fbdd in Curl_resolv (data=0x8187a68,
    hostname=0xbdbff888 "192.168.1.2", port=3203) at hostip.c:213
#3 0x40038289 in ftp_use_pasv (conn=0x8171bf0) at ftp.c:1466
#4 0x40038661 in ftp_perform (conn=0x8171bf0) at ftp.c:1611
#5 0x400392e6 in Curl_ftp (conn=0x8171bf0) at ftp.c:2054
#6 0x4003d585 in Curl_do (connp=0xbdbffa68) at url.c:2428
#7 0x40049681 in Curl_perform (data=0x8187a68) at transfer.c:1139
#8 0x40049fbc in curl_easy_perform (curl=0x8187a68) at easy.c:245
#9 0x08048d8b in get_urls (my_t_info_arg=0x804b7c0) at urlgrab.c:131
#10 0x4001c0ba in pthread_start_thread () from /lib/libpthread.so.0
#11 0x4001c101 in pthread_start_thread_event () from /lib/libpthread.so.0
(gdb)

With 2 threads:

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1026 (LWP 762)]
0x400c0a3b in free () from /lib/libc.so.6
(gdb) bt
#0 0x400c0a3b in free () from /lib/libc.so.6
#1 0x4002fd5f in Curl_freeaddrinfo (freethis=0x8053ee0) at hostip.c:264
#2 0x4004b5f8 in _hash_element_dtor (user=0x8068be8, element=0x8069578)
    at hash.c:66
#3 0x4004b42a in Curl_llist_remove (list=0x8068c68, e=0x80695a0,
    user=0x8068be8) at llist.c:134
#4 0x4004bbe9 in Curl_hash_clean_with_criterium (h=0x8068be8,
    user=0xbf7ff7ec, comp=0x4002fae8 <_curl_hostcache_timestamp_remove>)
    at hash.c:271
#5 0x4002fb5c in hostcache_prune (hostcache=0x8068be8, cache_timeout=60,
    now=1022247472) at hostip.c:182
#6 0x4002fbdd in Curl_resolv (data=0x8054440,
    hostname=0xbf7ff888 "192.168.1.2", port=3350) at hostip.c:213
#7 0x40038289 in ftp_use_pasv (conn=0x8068d20) at ftp.c:1466
#8 0x40038661 in ftp_perform (conn=0x8068d20) at ftp.c:1611
#9 0x400392e6 in Curl_ftp (conn=0x8068d20) at ftp.c:2054
#10 0x4003d585 in Curl_do (connp=0xbf7ffa68) at url.c:2428
#11 0x40049681 in Curl_perform (data=0x8054440) at transfer.c:1139
#12 0x40049fbc in curl_easy_perform (curl=0x8054440) at easy.c:245
#13 0x08048d8b in get_urls (my_t_info_arg=0x804b6e0) at urlgrab.c:131
#14 0x4001c0ba in pthread_start_thread () from /lib/libpthread.so.0
#15 0x4001c101 in pthread_start_thread_event () from /lib/libpthread.so.0
(gdb)

Today or Tuesday, I'll try to cut the program down to the bare essentials
that still make libcurl crash.

Avery Fay

|---------+---------------------------->
| | Daniel Stenberg |
| | <daniel_at_haxx.se> |
| | |
| | 05/22/2002 05:48 |
| | PM |
| | |
|---------+---------------------------->
>------------------------------------------------------------------------------------------------------------------------------|
  | |
  | To: Avery Fay <avery_fay_at_symantec.com> |
  | cc: libcurl Mailing list <curl-library_at_lists.sourceforge.net> |
  | Subject: Re: Bug in libcurl in multithreaded program |
>------------------------------------------------------------------------------------------------------------------------------|

On Wed, 22 May 2002, Avery Fay wrote:

> I wasn't aware of the CURLOPT_DNS_USE_GLOBAL_CACHE option. (Is the
default
> on?

No, it defaults to FALSE/off.

> In this case, the example multithreaded program should be updated)
However,
> even after I set it to false the problem persists.

Does it still give you the same stack trace? The trace looks a bit funny
(the
double Curl_ftp_done for example) but it seems as if the code believes the
global DNS cache is enabled.

Can you build libcurl with -g (and without -O or -O2) to get a more
detailed
stack trace from the crash?

> My program is fairly simple. Basically, generate a list of ftp and http
> urls to a specified server. Create a bunch of threads. Each thread
randomly
> picks a url from the list, fetches the file, and repeats. In terms of
using
> libcurl, the only functions i'm using are curl_easy_init and curl_setopt
to
> set the url. Since the threads keep on fetching until the program is
killed
> I never call curl_easy_cleanup. I've tried compiling both the library and
> my program with gcc -O0 (no optimizations) but the segfaulting persists.

Can you make a (possibly edited) version available for us that we can try
to
repeat this problem with?

Can you make it happen using only two threads?

--
    Daniel Stenberg -- curl groks URLs -- http://curl.haxx.se/
_______________________________________________________________
Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
Received on 2002-05-24