cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Detection of HAVE_GETADDRINFO_THREADSAFE in configure

From: Mason <mpeg.blue_at_free.fr>
Date: Fri, 30 Mar 2012 11:37:28 +0200

Yang Tse wrote:

> Mason wrote:
>
>> Neither atoi nor strtol are mentioned in the list, therefore atoi
>> and strtol must be thread-safe on POSIX-compliant implementations
>> (otherwise it's an implementation bug, which may happen).
>>
>> Are you saying atoi is not thread-safe because it might call
>> isspace, which might be affected by setlocale?
>
> From a practical point of view, whether atoi() is thread-safe and
> async-cancel-safe should be considered as being implementation
> dependent. On the safe side, not thread safe. POSIX may dictate
> whatever they choose, but software has bugs and not all
> compilers/libraries pass same QA tests.
>
> atoi() is one of the functions that should have been dropped in POSIX
> SBS issue 7. There's no way to tell apart a 'proper' zero result from
> a 'bad' zero result. http://www.codepolice.org/c/atoi.html
>
> Regarding lwIP getaddrinfo() thread-safeness, let's stop this here.
> Ask the lwIP Team to document whether lwip_getaddrinfo() is
> thread-safe or not and we'll adapt if it is documented to be
> thread-safe and its implementation removes atoi() usage.

Last week, I fixed a bug[1] in lwip_gethostbyname_r that made libcurl
crash. I figured I might work on lwip_getaddrinfo in my spare time.

[1] https://savannah.nongnu.org/bugs/?35907

Is strtol an acceptable replacement for atoi? (Probably not; if atoi
is not thread-safe, odds are good that strtol is not either, since
many libraries implement atoi as a wrapper to strtol.)

Looking at the libcurl source code, it seems strtol is used in several
places, if it is available. (There's also one call to atoi in telnet.c)

-- 
Regards.
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2012-03-30