Date: Fri, 26 Mar 2004 14:23:56 -0800 From: Sean McNeil <sean@mcneil.com> To: "Jacques A. Vidrine" <nectar@freebsd.org> Cc: freebsd-current@freebsd.org Subject: libc using pthread routines (was nss_ldap broken) Message-ID: <1080339836.31925.17.camel@server.mcneil.com> In-Reply-To: <1080335779.11426.15.camel@server.mcneil.com> References: <1080273717.18231.10.camel@server.mcneil.com> <20040326125934.GA68357@madman.celabo.org> <1080334840.11426.12.camel@server.mcneil.com> <1080335779.11426.15.camel@server.mcneil.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 2004-03-26 at 13:16, Sean McNeil wrote: > On Fri, 2004-03-26 at 13:00, Sean McNeil wrote: > > OK, I think I understand this problem... > > > > When I have my nsswitch.conf setup as follows, I get seg11s: > > > > passwd: files ldap > > group: files ldap > > > > This appears to be an issue with any external nss_*.so.1 module that > > uses pthread. It looks to me it is about the following: > > > > /* > > * Cleanup > > */ > > static void > > nss_atexit(void) > > { > > (void)_pthread_rwlock_wrlock(&nss_lock); > > VECTOR_FREE(_nsmap, &_nsmapsize, sizeof(*_nsmap), > > (vector_free_elem)ns_dbt_free); > > VECTOR_FREE(_nsmod, &_nsmodsize, sizeof(*_nsmod), > > (vector_free_elem)ns_mod_free); > > (void)_pthread_rwlock_unlock(&nss_lock); > > } > > > > In my case, the nss_ldap.so.1 module was loaded which pulls in > > libpthread. I'm not sure how this works without a libpthred, but it > > would appear that unless libpthread.so is loaded everything is OK. But > > now, it has been loaded and the rwlock_wrlock() works, but then it has > > been unloaded before rwlock_unlock() gets called. > > > > Would using > > > > #include <reentrant.h> > > rwlock_wrlock() > > rwlock_unlock() > > > > macros fix this? > > > > Cheers, > > Sean > > > > Final thought: exit() sets __isthreaded to 0, so I am hazarding a guess > that the lock isn't necessary. Removing the lock/unlock from > nss_atexit() did the trick. > > Sean > I was looking at this wrong. __isthreaded is set to 0 as an initializer, so I guess there is a need to lock and unlock in the atexit routine. I am very puzzled about these routines. net/nsdispatch.c is the only file in libc that uses the _pthread_ routines directly. Others use the macros that test __isthreaded. The macros, however, will not provide the status of the call back. The most peculiar thing about it all is I cannot see how these are resolved if no thread library is loaded. How does this mechanism work? I see that the routines in question are marked as "W" by nm. So if a thread library doesn't get loaded in this routine resolves to 0? And a call to 0 returns ok? Can someone help out this confused soul? Sean
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1080339836.31925.17.camel>