From owner-freebsd-threads@FreeBSD.ORG Thu Sep 23 17:40:01 2010 Return-Path: Delivered-To: freebsd-threads@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E7A6A1065693 for ; Thu, 23 Sep 2010 17:40:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id AAD038FC17 for ; Thu, 23 Sep 2010 17:40:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o8NHe1A2021308 for ; Thu, 23 Sep 2010 17:40:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o8NHe1Ga021307; Thu, 23 Sep 2010 17:40:01 GMT (envelope-from gnats) Resent-Date: Thu, 23 Sep 2010 17:40:01 GMT Resent-Message-Id: <201009231740.o8NHe1Ga021307@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-threads@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Christopher Faylor Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0E492106566B for ; Thu, 23 Sep 2010 17:33:57 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id F197D8FC1A for ; Thu, 23 Sep 2010 17:33:56 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o8NHXu7M082525 for ; Thu, 23 Sep 2010 17:33:56 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o8NHXuao082524; Thu, 23 Sep 2010 17:33:56 GMT (envelope-from nobody) Message-Id: <201009231733.o8NHXuao082524@www.freebsd.org> Date: Thu, 23 Sep 2010 17:33:56 GMT From: Christopher Faylor To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: threads/150889: PTHREAD_MUTEX_INITIALIZER + pthread_mutex_destroy() == EINVAL X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Sep 2010 17:40:02 -0000 >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: