problem when pthread_* functions are invoked from dynamiclibrary

Joakim Tjernlund joakim.tjernlund at transmode.se
Sat Dec 3 20:01:40 UTC 2005


 
> 
> On Fri, Dec 02, 2005 at 05:46:07PM +0530, Kishore K wrote:
> > I am facing some problems if pthread_self() and some other 
> pthread_* 
> > functions are invoked from a dynamic library.
> 
> ok, we chatted on irc and some others (mjn3/andersee) have 
> been reporting similar behavior ... however, everyone has 
> been using mips, so there was some suspicion that it's a 
> mips-specific bug in ldso (which wouldnt be the first time 
> this happened ...)
> 
> with that in mind, i just gave your code a spin on an armeb /
> uclibc-0.9.28 host and got the same results ... linking test 
> against -lpthread would fix the output
> 
> btw, this command:
> > $mips-linux-gcc -shared -o libthreadTest.so threadTest.c -lpthread
> should contain -fPIC, but that's unrelated to the issue at hand :)
> 
> > Again, if the following line is commented out
> >         weak_alias (__pthread_return_0, pthread_self) from 
> > libc/misc/weaks.c in uClibc source code
> 
> i just cleaned up weaks.c and removed all the weaks that 
> libc.so itself does not require (which includes pthread_self) 
> ... but, that doesnt change the fact that the mechanism in 
> ldso to handle weaks appears to be broken ...
> -mike

I don't think weak handling is broken. Some time ago glibc changed is weak
handling and I did the same to uClibc. I don't know why this change was done.
In glibc you can set LD_DYNAMIC_WEAK=1 to use the old method.

With the current weak procedure one must make sure pthread.so is loaded
before libc.so to get the expected behaviour. I belive that this is not the
case above.

If you want to use the old weak procedure in uClibc, you can change the
#if 0 to #if 1 in _dl_find_hash

I also think that the remaining weak pthread functions in libc.so is broken, due
to the current weak symbol procedure.

Not sure if it's a good idea to revert to the old weak method, probably other
apps will break if we do.

 Jocke




More information about the uClibc mailing list