cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Crash in gethostbyname_r?

From: Daniel Stenberg <daniel-curl_at_haxx.se>
Date: Mon, 16 Feb 2004 09:10:19 +0100 (CET)

On Mon, 16 Feb 2004, Nathan O'Sullivan wrote:

> Here's a copy of the output from gdb for the threads running at the time of
> the crash.

Each simultaneous thread is using its own curl handle, right? (the stack
traces seem to show separate curl handles, I'm just asking to be absolutely
sure)

You mentioned your glibc version, but can you single-step trough the
gethostbyname_r() usage to see how it behaves? I mean, does it return
errno-codes or -1, and does it use ERANGE or EAGAIN when the target buffer is
too small? The glibc gethostbyname_r() situation is "confused", to express it
in a gentle way.

> #2 0x080faca5 in gethostbyname_r ()
> #3 0x08065f2d in my_getaddrinfo (conn=0x0, hostname=0x40408a08
> "my.domain.com", port=80, waitp=0x0) at hostip.c:982
> #4 0x08065b95 in Curl_resolv (conn=0x404089a8, hostname=0x40408a08
> "my.domain.com", port=80, entry=0xbe1ff060) at hostip.c:335
> #5 0x08069e29 in CreateConnection (data=0x40400490, in_connect=0xbe1ff830,
> addr=0xbe1ff804, async=0xbe1ff837 "") at url.c:3006

This looks very strange. conn is zero when my_getaddrinfo() gets called, or at
least when this stack trace is produced.

How often does this happen? Would you be able to set a (conditional)
break-point in there or possibly add some debug-logging or something to help
us understanding the situation when conn is zero like this? conn set to zero
won't cause the crash in gethostbyname_r(), but it indicates an earlier
problem. 'waitp' is a pointer to an int, it should not be zero at this point
either.

> [Switching to thread 3 (process 10340)]#0 0x400e0d76 in ?? ()
> (gdb) bt

> #8 0x080faca5 in gethostbyname_r ()
> #9 0x08065f2d in my_getaddrinfo (conn=0xfffffffc, hostname=0x81d7a50
> "my.domain.com", port=80, waitp=0xfffffffc) at hostip.c:982
> #10 0x08065b95 in Curl_resolv (conn=0x81d79f0, hostname=0x81d7a50
> "my.domain.com", port=80, entry=0xbdfff060) at hostip.c:335
> #11 0x08069e29 in CreateConnection (data=0x81cf6d8, in_connect=0xbdfff830,
> addr=0xbdfff804, async=0xbdfff837 "") at url.c:3006

This too has weird conn and waitp contents in the call to my_getaddrinfo().

I get the feeling this is a multi-threaded problem hiding somewhere in the
libcurl code.

You're not using a global DNS cache, are you?

> (gdb) bt
> #4 0x080fac1c in gethostbyname_r ()
> #5 0x08065f2d in my_getaddrinfo (conn=0xfffffffe, hostname=0x4040b6e8
> "my.domain.com", port=80, waitp=0xfffffffe) at hostip.c:982

Weirdo again.

-- 
    Daniel Stenberg -- http://curl.haxx.se/ -- http://daniel.haxx.se/
   [[ Do not send mails to this email address. They won't reach me. ]]
Received on 2004-02-16