On Wed, Dec 12, 2012 at 01:17:18PM +0000, Erik wrote:
> Hi,
> 
> [Please keep me on CC:, I'm not subscribed]
> 
> I'm working with current uClibc on a system with 2 CPU cores and had problems
> with gethostbyname() function if several threads will use it together.
> 
> The congruent usage of gethostbyname() (uClibc-9.32.1) by at least two threads
> can cause a crash in resolv.c : __read_etc_hosts_r(). The crash occurs
> independently from the "resolve" result.
> Root cause is a NULL pointer dereference in strcasecmp().

gethostbyname is not thread-safe. This is not an implementation bug;
it's a fundamental flaw in the interface design, since it has to
return static storage. If you want a thread-safe version you should be
using gethostbyname_r. Really, you should be using the modern
interface, getaddrinfo, and forgetting you ever heard of
gethostbyname, since we're almost in 2013 and gethostbyname, by
design, cannot support IPv6.

Rich
_______________________________________________
uClibc mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/uclibc

Reply via email to