Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Sep 2004 15:29:32 +0100
From:      "Chris Stenton" <jacs@gnome.co.uk>
To:        "Daniel Eischen" <deischen@freebsd.org>
Cc:        freebsd-current@freebsd.org
Subject:   Re: daemon threads bug with libpthread
Message-ID:  <00da01c4a0b0$93b46d60$037ba8c0@gnome.co.uk>
References:  <Pine.GSO.4.43.0409220753140.857-100000@sea.ntplx.net>

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

As you can see I do a pthread_join before the daemon call so all threads 
should be closed at that point. There must be some residual state left.

Chris

----- Original Message ----- 
From: "Daniel Eischen" <deischen@freebsd.org>
To: "Chris Stenton" <jacs@gnome.co.uk>
Cc: <freebsd-current@freebsd.org>; <threads@freebsd.org>
Sent: Wednesday, September 22, 2004 12:59 PM
Subject: Re: daemon threads bug with libpthread


> On Wed, 22 Sep 2004, 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.
>
> daemon() calls fork().  I don't think you can create a threaded
> program after a fork if you are already threaded.  You have to
> wait to do any threading (including mutexes and stuff) until
> after the fork.
>
> When you call daemon() there is already a thread and perhaps
> some locks in the library (libc and libpthread).  After the
> fork, the parent exits and the child is left.  You are single
> threaded after the fork (as defined by POSIX), but libpthread
> and libc have locks that may be locked by threads created
> before the fork.
>
>> 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.
>>
>> Here is some test code. I am running FreeBSD 5.3-beta
>>
>> Please reply directly as I am not on the mailing list
>
> -- 
> Dan Eischen
> 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?00da01c4a0b0$93b46d60$037ba8c0>