From owner-freebsd-threads@FreeBSD.ORG Tue Oct 26 23:20:07 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 412741065675 for ; Tue, 26 Oct 2010 23:20:07 +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 022C88FC22 for ; Tue, 26 Oct 2010 23:20:07 +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 o9QNK6f0079827 for ; Tue, 26 Oct 2010 23:20:06 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o9QNK6kK079826; Tue, 26 Oct 2010 23:20:06 GMT (envelope-from gnats) Resent-Date: Tue, 26 Oct 2010 23:20:06 GMT Resent-Message-Id: <201010262320.o9QNK6kK079826@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, Mark Terribile Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 93C5A1065674 for ; Tue, 26 Oct 2010 23:13:23 +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 67B008FC08 for ; Tue, 26 Oct 2010 23:13:23 +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 o9QNDNNO094864 for ; Tue, 26 Oct 2010 23:13:23 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o9QNDN6I094853; Tue, 26 Oct 2010 23:13:23 GMT (envelope-from nobody) Message-Id: <201010262313.o9QNDN6I094853@www.freebsd.org> Date: Tue, 26 Oct 2010 23:13:23 GMT From: Mark Terribile To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: threads/151767: pthread_mutex_init returns success with bad attributes; SUBSEQUENT operations fail 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: Tue, 26 Oct 2010 23:20:07 -0000 >Number: 151767 >Category: threads >Synopsis: pthread_mutex_init returns success with bad attributes; SUBSEQUENT operations fail >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-threads >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Oct 26 23:20:06 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Mark Terribile >Release: 7.2 >Organization: >Environment: FreeBSD gold.local 7.2-RELEASE FreeBSD 7.2-RELEASE #3: Mon Nov 16 12:48:52 EST 2009 toor@silver.local:/usr/obj/usr/src/sys/SMP-GONDOLIN i386 >Description: 1) A pthread_mutexattr_t is initialized and then parameters are set. Some are unsupported or invalid, as shown below. All the operations return success. 2) The pthread_mutex_attr_t is used in the initialization of a pthread_mutex_t. The pthread_mutex_init returns success. 3) A subesequent operation (pthread_mutex_lock, pthread_mutex_destroy) on the mutex in question returns EINVAL. This delayed reporting makes finding an error very difficult, and is probably not correct. Can the pthread_mutex_init be said to succeed if the mutex cannot be used for anything without generating an EINVAL? I understand that 7.2 is not a supported release, but this problem does not seem to appear in the bug reports so it is likely also present in later releases. An upgrade at this site right now is not feasible; I need a very stable environment underneath me. >How-To-Repeat: Please refer to the code below. All operations up to the #if return 0. If the lock/unlock code is #if'd out, the pthread_mutex_destroy returns 22. If the lock/unlock code is #if'd in, the pthread_mutex_lock returns 22, the pthread_mutex_unlock returns 2 (probably correct, given the other errors) and the pthread_mutex_destroy still returns 22. #include #include int main() { pthread_mutexattr_t ma; int r = pthread_mutexattr_init( &ma ); printf( "mutexattr init %d\n", r ); r = pthread_mutexattr_setprotocol( &ma, PTHREAD_PRIO_PROTECT ); printf( "mutexattr setprotocol %d\n", r ); r = pthread_mutexattr_settype( &ma, PTHREAD_MUTEX_ERRORCHECK ); printf( "mutexattr settype %d\n", r ); r = pthread_mutexattr_setprioceiling( &ma, 2 ); printf( "mutexattr setprioceiling %d\n", r ); pthread_mutex_t mtx; r = pthread_mutex_init( &mtx, &ma ); printf( "mutex init %d\n", r ); #if 0 r = pthread_mutex_lock( &mtx ); printf( "mutex lock %d\n", r ); r = pthread_mutex_unlock( &mtx ); printf( "mutex unlock %d\n", r ); #endif r = pthread_mutex_destroy( &mtx ); printf( "mutex destroy %d\n", r ); return 0; } >Fix: >Release-Note: >Audit-Trail: >Unformatted: