Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Sep 2004 19:47:09 +0300
From:      Mike Makonnen <mtm@identd.net>
To:        Chris Stenton <jacs@gnome.co.uk>
Cc:        freebsd-current@freebsd.org
Subject:   Re: daemon threads bug with libpthread
Message-ID:  <20040922164709.GA14929@rogue.acs.lan>
In-Reply-To: <1095840348.23443.14.camel@hawk.gnome.co.uk>
References:  <1095840348.23443.14.camel@hawk.gnome.co.uk>

next in thread | previous in thread | raw e-mail | index | archive | help

--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--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040922164709.GA14929>