From owner-freebsd-current@FreeBSD.ORG Fri Mar 26 15:58:12 2004 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 9B0C916A4CE; Fri, 26 Mar 2004 15:58:12 -0800 (PST) Received: from ms-smtp-02-eri0.socal.rr.com (ms-smtp-02-qfe0.socal.rr.com [66.75.162.134]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8525443D41; Fri, 26 Mar 2004 15:58:12 -0800 (PST) (envelope-from sean@mcneil.com) Received: from mail.mcneil.com (cpe-24-24-233-222.socal.rr.com [24.24.233.222])i2QNw9Sa004444; Fri, 26 Mar 2004 15:58:09 -0800 (PST) Received: from localhost (localhost.mcneil.com [127.0.0.1]) by mail.mcneil.com (Postfix) with ESMTP id 6BA5DFD018; Fri, 26 Mar 2004 15:58:09 -0800 (PST) Received: from mail.mcneil.com ([127.0.0.1]) by localhost (server.mcneil.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 73897-10; Fri, 26 Mar 2004 15:58:09 -0800 (PST) Received: from [24.24.233.222] (mcneil.com [24.24.233.222]) by mail.mcneil.com (Postfix) with ESMTP id EF4F1FD008; Fri, 26 Mar 2004 15:58:08 -0800 (PST) From: Sean McNeil To: Daniel Eischen In-Reply-To: References: Content-Type: text/plain Message-Id: <1080345488.10339.3.camel@server.mcneil.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Fri, 26 Mar 2004 15:58:08 -0800 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Symantec AntiVirus Scan Engine X-Virus-Scanned: by amavisd-new at mcneil.com cc: "Jacques A. Vidrine" cc: freebsd-current@freebsd.org Subject: Re: nss_ldap broken X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Mar 2004 23:58:12 -0000 On Fri, 2004-03-26 at 15:53, Daniel Eischen wrote: > On Fri, 26 Mar 2004, Sean McNeil wrote: > > > > > On Fri, 2004-03-26 at 14:51, Daniel Eischen wrote: > > > > > > I think I made a comment about how you should always > > > prefix _pthread_foo() calls with 'if (__isthreaded)'. > > > > > > When the thread libraries are initialized, then overrwrite > > > the function pointers in libc's thread jumptable. If you > > > unload the library, libc still retains those pointers. > > > > Yes, checking __isthreaded solves my problem. nsdispatch.c has several > > calls to _thread* routines that should be protected by the __isthreaded > > test. > > > > It would appear that even though RTLD_LOCAL is used on the dlopen, since > > nss_ldap.so.1 is linked with libc as well it causes those thread > > jumptable entries to be modified. When dlclose is called the reference > > count to the thread library goes to zero, the library is unloaded, and > > the pointers are now no good. > > > > This poses an interesting problem, though. Since there is a dlopen in > > this it is possible for part of a function to have __isthreaded not set > > and part of it set. For these routines the value of __isthreaded would > > need to be stashed. Yet for the nss_atexit, since it is the opposite > > direction (dlclose), the variable would have to be tested directly. > > Once something is threaded, I think it always has to be > threaded. We don't support going back to unthreaded mode. > > I'm not sure how all this works with nss_ldap (and perhaps > other modules) and why they are bringing in the threads > library. What dependency is bringing in the threads library > in the first place? Both nss_ldap.so.1 has some threaded code and one of it's dependencies, libsasl2.so.2, brings is pthread as well. Sean