You are not logged in.
I have been trying to troubleshoot some crashes I experienced in an application I wrote that makes use of libcurl. Running it on an updated version of Arch (glibc 2.19-2, curl 7.35.0-1), it crashes randomly. At first I thought it was my code and later on that libcurl could possibly be to blame. Looking at the backtraces, I guess that there is something else going on, and I wonder if anyone has a solution.
For completeness I also tested the very same code on Oracle Linux 6.4 (essentially the same as Red Hat Enterprise Linux 6.4) where it works no problems at all (glibc-2.12-1.107, curl-7.19.7-37).
In an attempt to isolate the problem, I wrote this simple client which uses libcurl:
#include <stdio.h>
#include <unistd.h> /* UNIX standard function definitions */
#include <curl/curl.h>
int main (int argc, char **argv) {
CURL *curl;
CURLcode res;
char *url = "http://bbs.archlinux.org";
curl_global_init(CURL_GLOBAL_DEFAULT);
while (1) {
curl = curl_easy_init();
if(curl) {
curl_easy_setopt(curl, CURLOPT_URL, url);
//~ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
//~ curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&chunk);
curl_easy_setopt(curl, CURLOPT_FORBID_REUSE, 1L); //mimic real world use
curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1L); //disable signals to use with threads
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
res = curl_easy_perform(curl);
if (res != 0) {
printf("curl_easy_perform() failed: %s\n", curl_easy_strerror(res));
}
curl_easy_cleanup(curl);
}
sleep(15);
}
curl_global_cleanup();
return 0;
}
Running it in gdb using the folling command line, I can produce a backtrace quoted below.
$ MALLOC_CHECK_=2 gdb --args ./curltest
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
* Rebuilt URL to: http://bbs.archlinux.org/
* Hostname was NOT found in DNS cache
[New Thread 0x7ffff4f21700 (LWP 16716)]
Program received signal SIGABRT, Aborted.
0x00007ffff6fbd389 in raise () from /usr/lib/libc.so.6
(gdb) thread apply all bt full
Thread 2 (Thread 0x7ffff4f21700 (LWP 16716)):
#0 0x00007ffff706ea5d in connect () from /usr/lib/libc.so.6
No symbol table info available.
#1 0x00007ffff709f19c in open_socket () from /usr/lib/libc.so.6
No symbol table info available.
#2 0x00007ffff709fc28 in __nscd_open_socket () from /usr/lib/libc.so.6
No symbol table info available.
#3 0x00007ffff709da0b in __nscd_getai () from /usr/lib/libc.so.6
No symbol table info available.
#4 0x00007ffff70594fa in gaih_inet () from /usr/lib/libc.so.6
No symbol table info available.
#5 0x00007ffff705b26d in getaddrinfo () from /usr/lib/libc.so.6
No symbol table info available.
#6 0x00007ffff7bafe34 in ?? () from /usr/lib/libcurl.so.4
No symbol table info available.
#7 0x00007ffff7bbba94 in ?? () from /usr/lib/libcurl.so.4
No symbol table info available.
#8 0x00007ffff7bba5bb in ?? () from /usr/lib/libcurl.so.4
No symbol table info available.
#9 0x00007ffff595f0a2 in start_thread () from /usr/lib/libpthread.so.0
No symbol table info available.
#10 0x00007ffff706dd1d in clone () from /usr/lib/libc.so.6
No symbol table info available.
Thread 1 (Thread 0x7ffff7fa6740 (LWP 16712)):
#0 0x00007ffff6fbd389 in raise () from /usr/lib/libc.so.6
No symbol table info available.
#1 0x00007ffff6fbe788 in abort () from /usr/lib/libc.so.6
No symbol table info available.
#2 0x00007ffff70009e0 in malloc_printerr () from /usr/lib/libc.so.6
No symbol table info available.
#3 0x00007ffff7b91e18 in ?? () from /usr/lib/libcurl.so.4
No symbol table info available.
#4 0x00007ffff7ba3a90 in ?? () from /usr/lib/libcurl.so.4
No symbol table info available.
#5 0x00007ffff7ba45e1 in curl_multi_perform () from /usr/lib/libcurl.so.4
No symbol table info available.
#6 0x00007ffff7b9bc13 in curl_easy_perform () from /usr/lib/libcurl.so.4
No symbol table info available.
#7 0x0000000000400bef in main (argc=1, argv=0x7fffffffe0b8) at testmongo.c:48
curl = 0x6506a0
res = CURLE_OK
url = 0x400cb8 "http://bbs.archlinux.org"
Not sure where to go from here. In #curl on freenode, I was told that getaddrinfo failures often seen in multi threaded programs when using the basic resolver. Not sure what to do with that information. The ArchLinux curl is built with --enabled-threaded-resolver as far as I can see in the PKGBUILD.
Last edited by Hermann (2014-04-22 16:09:01)
Offline
Fedora reckons name resolution has problems - there's a lot of open bug reports for getaddrinfo.
Check your 127.0.0.1
Offline
Found the reason for the random crashes. Had left -lmcheck as a compiler option in the Makefile, which is a bad thing to do, as it isn't thread safe and libcurl uses threads.
Offline