OSDN Git Service

LT.old: Make __errno_location/__h_errno_location thread safe
authorVineet Gupta <vgupta@synopsys.com>
Wed, 16 Apr 2014 09:57:52 +0000 (15:27 +0530)
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Wed, 23 Apr 2014 11:21:03 +0000 (13:21 +0200)
commit8f550715c2b211036fc273add3cb5219397ed312
treeb879f37f1ce879c1785c975b5dbdb38db603e71b
parent5799194b75b238491501cbb122f5d7025edd3aa2
LT.old: Make __errno_location/__h_errno_location thread safe

WHY: errno in uClibc is not thread safe

HOW: __errno_location and it's sibling __h_errno_location need to be called
     via PLT - even from within libc. That way when linked with pthread,
     intra-uClibc callers will also use the thread safe version.

     This is achieved by removing the GI alias for these functions,
     ensuring that they get called normally (via PLT)

Verified with ARC LT.old and ARM cubieboard2 buildroot (LT.old)
NPTL is unaffected by this bug.

------------ History behind this patch ---------------------

This is a long standing bug (https://bugs.busybox.net/show_bug.cgi?id=2089)

Others have tried to fix it in past (alteast Peter Korsgaard's patch in 2010),
but somehow failed to be merged (or were backed out afterwards).
http://lists.uclibc.org/pipermail/uclibc/2010-July/044176.html

One of the causes could be side effect of atleast one more bug related to
pthreads and static link which has now been fixed.
http://lists.uclibc.org/pipermail/uclibc/2013-October/047958.html

I have solved this w/o looking at other pacthes but would like to give
credit to Peter and others for confirming that it makes sense.

Cc: Christian Ruppert <christian.ruppert@abilis.com>
CC: Francois Bedard <Francois.Bedard@synopsys.com>
Cc: Joern Rennecke <joern.rennecke@embecosm.com>
Cc: Jeremy Bennett <jeremy.bennett@embecosm.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Peter Korsgaard <peter@korsgaard.com>
Cc: Khem Raj <raj.khem@gmail.com>
Cc: buildroot@busybox.net
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
include/netdb.h
libc/misc/internals/__errno_location.c
libc/misc/internals/__h_errno_location.c
libc/sysdeps/linux/common/bits/errno.h