cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: libcurl-7.17.1 crashes on getprotobyname() problem in RHEL5.1

From: Michal Marek <mmarek_at_suse.cz>
Date: Fri, 02 May 2008 21:18:46 +0200

Dan Fandrich napsal(a):
> On Fri, May 02, 2008 at 11:26:04AM -0400, Jean-François Bertrand wrote:
>> -- Problem description --
>> libcurl is causing segfault on calls to getprotobyname("ftp") when doing
                                                           ^^^ tcp?

>> simultaneous access (from many threads) to unavailable HTTP resources
>> using libcurl-7.17.1. This occurs with RedHat Enterprise Linux 5.1
>> running on quad-core Intel(R) Xeon(R) CPU 5150 @ 2.66GHz system.
...
> It looks like your app is linking against the ISC bind resolver instead of
> glibc's NSS resolver. A quick look of the ISC source leads me to believe
> that it isn't thread safe, which would explain the crashes you're seeing
> in your multithreaded app.

OK, it seems that glibc serializes calls to getprotobyname internally.
But when curl reads the result in one thread, another thread might be
running inside getprotobyname() overwriting the static storage, which
isn't thread-safe either. There's getprotobyname_r which is really
thread-safe, but it works differently on different platforms. Also, the
number assigned to the TCP protocol doesn't change every week, so what
about just removing the call as Jean-François suggested and relying on
the IPPROTO_TCP constant?

Michal
Received on 2008-05-02