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

Christopher Faylor cgf at netapp.com
Thu Sep 23 17:40:02 UTC 2010


>Number:         150889
>Category:       threads
>Synopsis:       PTHREAD_MUTEX_INITIALIZER + pthread_mutex_destroy() == EINVAL
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-threads
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Sep 23 17:40:01 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Christopher Faylor
>Release:        6.x - head
>Organization:
NetApp
>Environment:
FreeBSD osg-cycf64a.nane.netapp.com 7.2-RELEASE FreeBSD 7.2-RELEASE #0: Fri May  1 07:18:07 UTC 2009     root at driscoll.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
Consider the following code snippet:

 pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
 int ret = pthread_mutex_destroy(&mutex);
 assert(ret == 0);

This code snippet will currently always hit the assertion.

This appears to be in contradiction to 

http://www.opengroup.org/onlinepubs/9699919799/toc.htm

which states:

  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.
>How-To-Repeat:
See description.
>Fix:
It seems like the simple fix is to change the ret = EINVAL in
lib/libthr/thread/thr_mutex.c to a ret = 0

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-threads mailing list