Date: Thu, 23 Sep 2010 17:33:56 GMT From: Christopher Faylor <cgf@netapp.com> To: freebsd-gnats-submit@FreeBSD.org Subject: threads/150889: PTHREAD_MUTEX_INITIALIZER + pthread_mutex_destroy() == EINVAL Message-ID: <201009231733.o8NHXuao082524@www.freebsd.org> Resent-Message-ID: <201009231740.o8NHe1Ga021307@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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@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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201009231733.o8NHXuao082524>