From owner-freebsd-stable@FreeBSD.ORG Thu Mar 20 07:48:36 2008 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DFFAF106564A for ; Thu, 20 Mar 2008 07:48:36 +0000 (UTC) (envelope-from modelnine@modelnine.org) Received: from jord.modelnine.org (jord.modelnine.org [83.246.72.120]) by mx1.freebsd.org (Postfix) with ESMTP id A865C8FC26 for ; Thu, 20 Mar 2008 07:48:36 +0000 (UTC) (envelope-from modelnine@modelnine.org) Received: from [192.168.1.38] (a89-182-206-17.net-htp.de [89.182.206.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: modelnine) by jord.modelnine.org (Postfix) with ESMTP id 37A65A37383 for ; Thu, 20 Mar 2008 08:31:08 +0100 (CET) From: Heiko Wundram To: freebsd-stable@freebsd.org Date: Thu, 20 Mar 2008 08:32:16 +0100 User-Agent: KMail/1.9.7 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200803200832.16340.modelnine@modelnine.org> Subject: pthread_mutexattr_settype non-conformance to man-page and POSIX X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Mar 2008 07:48:37 -0000 I hit a bug in libthr with pthread_mutexattr_settype which (at least as far as I understand the POSIX reference and also the man-page) makes it non-conformant to the specifications. Quoting: """ RETURN VALUES If successful, these functions return 0. Otherwise, an error number is returned to indicate the error. ... ERRORS ... The pthread_mutexattr_settype() function will fail if: [EINVAL] Invalid value for attr, or invalid value for type. """ This does not happen (at least not in libthr): """ int _pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) { int ret; if (attr == NULL || *attr == NULL || type >= PTHREAD_MUTEX_TYPE_MAX) { errno = EINVAL; ret = -1; } else { (*attr)->m_type = type; ret = 0; } return(ret); } """ The error code EINVAL is stored to errno, and -1 is returned, which is wrong at least according to my understanding of the man-page, which pretty much says the same thing as POSIX. I haven't looked yet whether this code has always been this way for FreeBSD, but at least under glibc[+NPTL], the error-number is returned directly as the return value (from a quick skimming of the sources), just as I would understand the specifications. The code in question is similar to pretty much all other functions in libthr, which also set errno and return -1, so basically it's a systematic error in the implementation of libthr, if I'm not completely mistaken. Anybody else have any more insight on this? -- Heiko Wundram