From owner-freebsd-current@FreeBSD.ORG Wed Sep 22 16:47:07 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 965FE16A4D1; Wed, 22 Sep 2004 16:47:07 +0000 (GMT) Received: from telecom.net.et (sparrow.telecom.net.et [213.55.64.50]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2D9CE43D5D; Wed, 22 Sep 2004 16:47:03 +0000 (GMT) (envelope-from mtm@identd.net) Received: from [213.55.68.240] (HELO rogue.acs.lan) by telecom.net.et (CommuniGate Pro SMTP 3.4.8) with ESMTP id 57966412; Wed, 22 Sep 2004 19:39:57 +0300 Received: by rogue.acs.lan (Postfix, from userid 1000) id 69110B86E; Wed, 22 Sep 2004 19:47:09 +0300 (EAT) Date: Wed, 22 Sep 2004 19:47:09 +0300 From: Mike Makonnen To: Chris Stenton Message-ID: <20040922164709.GA14929@rogue.acs.lan> References: <1095840348.23443.14.camel@hawk.gnome.co.uk> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="jRHKVT23PllUwdXP" Content-Disposition: inline In-Reply-To: <1095840348.23443.14.camel@hawk.gnome.co.uk> User-Agent: Mutt/1.4.2.1i X-Operating-System: FreeBSD/6.0-CURRENT (i386) cc: threads@freebsd.org cc: freebsd-current@freebsd.org Subject: Re: daemon threads bug with libpthread 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: Wed, 22 Sep 2004 16:47:07 -0000 --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Sep 22, 2004 at 09:05:48AM +0100, Chris Stenton wrote: > If you create a thread before calling daemon then the next thread you > create after the daemon call will cause the following error from the > libpthread library. > > Fatal error 'mutex is on list' at line 516 in file > /usr/src/lib/libpthread/thread/thr_mutex.c (errno = 0) > > This error does not occur if you link with -lc_r, linking with -lthr > causes a core dump. -lthr does not look very stable. Do you have any specific gripes with it? If so, please let me know. > > Here is some test code. I am running FreeBSD 5.3-beta > > Please reply directly as I am not on the mailing list The problem is with your test program. See the attached diff. After you apply it, it should work as expected. Cheers. -- Mike Makonnen | GPG-KEY: http://www.identd.net/~mtm/mtm.asc mtm@identd.net | Fingerprint: AC7B 5672 2D11 F4D0 EBF8 5279 5359 2B82 7CD4 1F55 mtm@FreeBSD.Org| FreeBSD - Unleash the Daemon ! --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="daemontest.diff" --- daemontest.c Wed Sep 22 18:43:36 2004 +++ daemontest2.c Wed Sep 22 19:43:11 2004 @@ -9,7 +9,7 @@ typedef struct { int data; - pthread_mutex_t *mut; + pthread_mutex_t mut; } simple; @@ -41,11 +41,11 @@ status = (simple *)arg; - pthread_mutex_lock (status->mut); + pthread_mutex_lock (&status->mut); status->data++; usleep(500000); printf("******slave me me me %d *********** \n",status->data ); - pthread_mutex_unlock (status->mut); + pthread_mutex_unlock (&status->mut); return (NULL); } @@ -59,11 +59,11 @@ for(; /* ever */ ;) { - pthread_mutex_lock (status->mut); + pthread_mutex_lock (&status->mut); status->data++; usleep(500000); printf("******slave2 me me me %d \n",status->data ); - pthread_mutex_unlock (status->mut); + pthread_mutex_unlock (&status->mut); } return (NULL); --jRHKVT23PllUwdXP--