From owner-freebsd-current@FreeBSD.ORG Mon Mar 29 18:44:42 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 E0CFE16A4D9; Mon, 29 Mar 2004 18:44:42 -0800 (PST) Received: from ms-smtp-03-eri0.socal.rr.com (ms-smtp-03-qfe0.socal.rr.com [66.75.162.135]) by mx1.FreeBSD.org (Postfix) with ESMTP id C376943D1F; Mon, 29 Mar 2004 18:44:42 -0800 (PST) (envelope-from sean@mcneil.com) Received: from mail.mcneil.com (cpe-24-24-233-222.socal.rr.com [24.24.233.222])i2U2idUL019906; Mon, 29 Mar 2004 18:44:40 -0800 (PST) Received: from localhost (localhost.mcneil.com [127.0.0.1]) by mail.mcneil.com (Postfix) with ESMTP id 73383FD08F; Mon, 29 Mar 2004 18:44:39 -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 50694-06; Mon, 29 Mar 2004 18:44:39 -0800 (PST) Received: from [24.24.233.222] (mcneil.com [24.24.233.222]) by mail.mcneil.com (Postfix) with ESMTP id 02786FD08A; Mon, 29 Mar 2004 18:44:38 -0800 (PST) From: Sean McNeil To: "Jacques A. Vidrine" In-Reply-To: <20040330023247.GA5637@madman.celabo.org> References: <1080334840.11426.12.camel@server.mcneil.com> <20040330023247.GA5637@madman.celabo.org> Content-Type: text/plain Message-Id: <1080614678.52004.5.camel@server.mcneil.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Mon, 29 Mar 2004 18:44:38 -0800 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Symantec AntiVirus Scan Engine X-Virus-Scanned: by amavisd-new at mcneil.com 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: Tue, 30 Mar 2004 02:44:43 -0000 On Mon, 2004-03-29 at 18:32, Jacques A. Vidrine wrote: > On Fri, Mar 26, 2004 at 05:51:02PM -0500, Daniel Eischen wrote: > > I think I made a comment about how you should always > > prefix _pthread_foo() calls with 'if (__isthreaded)'. > > Yes, I'm sure you did. My recollection was that it was an > optimization only, but it seems either I misunderstood or my > recollection is poor (or both) :-) > > > 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. > > OK, so we guard calls to threading routines with __isthreaded. (Patch > below.) Uglifies things a bit, but I can deal. Maybe some day we'll > rewrite reentrant.h so that it doesn't lose the return code (they > should all be like mutex_trylock?). > > > So, if I understand correctly: > > (1) __isthreaded starts out 0 > (2) When a threading library is loaded (by any cause? DT_NEEDED? > dlopen RTLD_GLOBAL? dlopen RTLD_LOCAL?), __isthreaded is set > to 1 > (3) When a threading library is unloaded, __isthreaded is reset to 0 > > Only, I don't immediately see where (3) happens... > > Sean, could you report how this patch works for you? Hmm, actually, it > looks almost identical to what you posted :-) Is there a reason that > you stored the value of `__isthreaded' in a local variable? Did that > make a difference for your case? > > Cheers, My reasoning behind storing in a local variable was this: 1) __isthreaded starts out 0 in those routines. 2) lock is called for unthreaded model (i.e. noop?) 3) module with pthreads gets loaded. 4) unlock is called for threaded model (i.e. real unlock of bogus lock) So I thought that if you didn't actually lock it threaded, then you shouldn't unlock it threaded. The most simple solution, I guess, is to just not unlock it in the nss_atexit. Since the program is going away it isn't really necessary. I think the more correct solution is the one I proposed. Cheers, Sean