daemon threads bug with libpthread
Mike Makonnen
mtm at identd.net
Wed Sep 22 09:47:07 PDT 2004
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 at identd.net | Fingerprint: AC7B 5672 2D11 F4D0 EBF8 5279 5359 2B82 7CD4 1F55
mtm at FreeBSD.Org| FreeBSD - Unleash the Daemon !
-------------- next part --------------
--- 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);
More information about the freebsd-threads
mailing list