From owner-freebsd-threads@FreeBSD.ORG Mon Jul 18 05:00:59 2005 Return-Path: X-Original-To: freebsd-threads@freebsd.org Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 4F50716A41C for ; Mon, 18 Jul 2005 05:00:59 +0000 (GMT) (envelope-from caelian@gmail.com) Received: from zproxy.gmail.com (zproxy.gmail.com [64.233.162.192]) by mx1.FreeBSD.org (Postfix) with ESMTP id B0FD143D49 for ; Mon, 18 Jul 2005 05:00:58 +0000 (GMT) (envelope-from caelian@gmail.com) Received: by zproxy.gmail.com with SMTP id 4so792174nzn for ; Sun, 17 Jul 2005 22:00:58 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:subject:from:to:cc:in-reply-to:references:content-type:date:message-id:mime-version:x-mailer:content-transfer-encoding; b=NIwo1xL6JnjRfX/OCOWPV+uLgNZ//4AtJsOyQ1z71gfKAmoOM0mpWNBhd0DRK7SoIpdjIldilyHiHAQE59rEE1t90/tEssQWfkduqvfnXjBH+E2g9c7Z6VisvzHxbbm6ONJp0xuWxUMuuBnhNwE1IqWv4FmVmYAYR+9vUJDHnbw= Received: by 10.36.220.55 with SMTP id s55mr3674249nzg; Sun, 17 Jul 2005 22:00:57 -0700 (PDT) Received: from ?192.168.15.103? ([68.190.230.198]) by mx.gmail.com with ESMTP id c12sm1870080nzc.2005.07.17.22.00.55; Sun, 17 Jul 2005 22:00:57 -0700 (PDT) From: Pascal Hofstee To: freebsd-threads@freebsd.org In-Reply-To: <1121453983.672.15.camel@synergy.charterpipeline.net.lan> References: <1121453983.672.15.camel@synergy.charterpipeline.net.lan> Content-Type: text/plain Date: Sun, 17 Jul 2005 22:00:53 -0700 Message-Id: <1121662853.701.10.camel@synergy.charterpipeline.net.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.3.5.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: David Ayers Subject: [PATCH] Re: GNUstep, libobjc and threading X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2005 05:00:59 -0000 On Fri, 2005-07-15 at 12:00 -0700, Pascal Hofstee wrote: > Is the above analysis enough information to hopefully fix this problem > with FreeBSD's threading libraries ... and would properly gaurding the > mentioned pthread_key_create function with a similar _thread_initial > check be sufficient ? Well .. i decided to give it a shot and tried to patch up libpthread myself with the information provided by David Ayers. And i have so far seen no ill-effects of my changes, but at least these GNUstep problems now are resolved. (GNUstep and FreeBSD/amd64 still don't exactly like eachother but that's because of at least a number of potential 64-bit issues which we're currently trying to resolve within GNUstep itself.) Below patches fix the problem as described in the analysis: --- lib/libpthread/thread/thr_spec.c.orig Sat Jul 16 19:28:31 2005 +++ lib/libpthread/thread/thr_spec.c Sat Jul 16 19:28:41 2005 @@ -50,8 +50,13 @@ int _pthread_key_create(pthread_key_t *key, void (*destructor) (void *)) { - struct pthread *curthread = _get_curthread(); + struct pthread *curthread; int i; + + if (_thr_initial == NULL) + _libpthread_init(NULL); + + curthread = _get_curthread(); /* Lock the key table: */ THR_LOCK_ACQUIRE(curthread, &_keytable_lock); --- lib/libthr/thread/thr_spec.c.orig Sat Jul 16 19:29:04 2005 +++ lib/libthr/thread/thr_spec.c Sat Jul 16 19:29:14 2005 @@ -52,8 +52,13 @@ int _pthread_key_create(pthread_key_t *key, void (*destructor) (void *)) { - struct pthread *curthread = _get_curthread(); + struct pthread *curthread; int i; + + if (_thr_initial == NULL) + _libpthread_init(NULL); + + curthread = _get_curthread(); /* Lock the key table: */ THR_LOCK_ACQUIRE(curthread, &_keytable_lock); I just realized it may be possible to do the whole _thr_initial dance inside the actual _get_curthread() function ... if that turns out to be the case .. perhaps that location would be more suitable than this 'stopgap'. With kind regards, Pascal Hofstee