From owner-freebsd-current@FreeBSD.ORG Sun Aug 15 14:53:25 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 77EC716A4CE; Sun, 15 Aug 2004 14:53:25 +0000 (GMT) Received: from itchy.rabson.org (mailgate.nlsystems.com [80.177.232.242]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6609643D48; Sun, 15 Aug 2004 14:53:24 +0000 (GMT) (envelope-from dfr@nlsystems.com) Received: from ns0.nlsystems.com (ns0.nlsystems.com [80.177.232.243]) by itchy.rabson.org (8.12.11/8.12.11) with ESMTP id i7FErK9I072787; Sun, 15 Aug 2004 15:53:20 +0100 (BST) (envelope-from dfr@nlsystems.com) From: Doug Rabson To: Daniel Eischen Date: Sun, 15 Aug 2004 15:53:32 +0100 User-Agent: KMail/1.6.2 References: In-Reply-To: MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200408151553.32463.dfr@nlsystems.com> X-Spam-Status: No, hits=0.0 required=5.0 tests=none autolearn=no version=2.63 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on itchy.rabson.org X-Virus-Scanned: clamd / ClamAV version 0.75.1, clamav-milter version 0.75c on itchy.rabson.org X-Virus-Status: Clean cc: Johan Pettersson cc: Stefan Ehmann cc: freebsd-current@freebsd.org Subject: Re: New nvidia drivers available 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: Sun, 15 Aug 2004 14:53:25 -0000 On Sunday 15 August 2004 15:03, Daniel Eischen wrote: > On Sun, 15 Aug 2004, Doug Rabson wrote: > > On Sunday 15 August 2004 14:47, Daniel Eischen wrote: > > > On Sun, 15 Aug 2004, Doug Rabson wrote: > > > > > Same error message here when starting neverball. If I map > > > > > libpthread->libc_r it's working again. > > > > > > > > > > xawtv also stopped working. Fortunately setting -xvport > > > > > manually did fix that. > > > > > > > > This might be because libGL calls libpthread's version of > > > > open() before libpthread has initialised properly. This patch > > > > might fix it - it fixes neverball's map compiler for me but I > > > > haven't actually run neverball itself. > > > > > > > > Index: thr_open.c > > > > =============================================================== > > > >==== RCS file: /home/ncvs/src/lib/libpthread/thread/thr_open.c,v > > > > retrieving revision 1.16 > > > > diff -u -r1.16 thr_open.c > > > > --- thr_open.c 9 Dec 2003 02:20:56 -0000 1.16 > > > > +++ thr_open.c 15 Aug 2004 09:19:42 -0000 > > > > @@ -45,11 +45,15 @@ > > > > int > > > > __open(const char *path, int flags,...) > > > > { > > > > - struct pthread *curthread = _get_curthread(); > > > > + struct pthread *curthread; > > > > int ret; > > > > int mode = 0; > > > > va_list ap; > > > > > > > > + if (_thr_initial == NULL) > > > > + _libpthread_init(NULL); > > > > + > > > > + curthread = _get_curthread(); > > > > > > I thought the C++ style constructor in thr_autoinit.c is supposed > > > to take care of things like this? > > > > The problem is that there is no particular ordering for > > constructors. In the case with neverball, the C++ constructor in > > libGL which initialises OpenGL ran first and quite reasonably tried > > to call open(2). This was intercepted by libpthread, which hadn't > > yet had its constructor called. > > Is there something else we can do so that libpthread gets > initialized first? Use _init()? I'm not sure how to > not add that when building static libpthread though (let's > kill static libpthread!). There is no way other than putting a special case for pthread initialisation into rtld. The C++ constructor trick is implemented via _init anyway so that won't work either. I have the same problem initialising TLS in static programs. My TLS initialisation must run before pthread initialises so that I can allocate the correct sized blocks for pthread's main thread. I ended up hooking the TLS initialisation directly from crt1.c before calling _init.