threads/150889: PTHREAD_MUTEX_INITIALIZER + pthread_mutex_destroy() == EINVAL

Thomas Mueller tmueller at sysgo.com
Fri Sep 24 09:00:15 UTC 2010


The following reply was made to PR threads/150889; it has been noted by GNATS.

From: Thomas Mueller <tmueller at sysgo.com>
To: John Baldwin <jhb at freebsd.org>
Cc: freebsd-threads at freebsd.org, freebsd-gnats-submit at freebsd.org,
 Christopher Faylor <cgf at netapp.com>
Subject: Re: threads/150889: PTHREAD_MUTEX_INITIALIZER +
 pthread_mutex_destroy() == EINVAL
Date: Fri, 24 Sep 2010 10:38:05 +0200

 On Thu, 23 Sep 2010 14:14:50 -0400, John Baldwin wrote:
 > On Thursday, September 23, 2010 1:33:56 pm Christopher Faylor wrote:
 > >   In cases where default mutex attributes are appropriate, the macro
 > >   PTHREAD_MUTEX_INITIALIZER can be used to initialize mutexes that are statically 
 > >   allocated. The effect shall be equivalent to dynamic initialization by a call to
 > >   pthread_mutex_init() with parameter attr specified as NULL, except that no error
 > >   checks are performed.
 > 
 > I suppose that is true, but I think this is also probably buggy code if you
 > are doing this.  The use case for PTHREAD_MUTEX_INITALIZER is static
 > initialization of static objects to ease adding locking to C libraries where
 > constructors are not easy.
 
 Note that future standard text might drop the "statically allocated"
 part in the pthread_mutex_init() description, see also
 http://www.austingroupbugs.net/view.php?id=70
 
 -- 
 Thomas Mueller


More information about the freebsd-threads mailing list