From owner-svn-src-all@FreeBSD.ORG Wed Sep 29 02:42:40 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1A1B0106564A; Wed, 29 Sep 2010 02:42:40 +0000 (UTC) (envelope-from davidxu@freebsd.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id DFC1F8FC27; Wed, 29 Sep 2010 02:42:39 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o8T2gbd7027871; Wed, 29 Sep 2010 02:42:38 GMT (envelope-from davidxu@freebsd.org) Message-ID: <4CA3181E.6030000@freebsd.org> Date: Wed, 29 Sep 2010 10:42:38 +0000 From: David Xu User-Agent: Thunderbird 2.0.0.24 (X11/20100630) MIME-Version: 1.0 To: Jung-uk Kim References: <201009280457.o8S4vuS9060037@svn.freebsd.org> <201009281202.22555.jkim@FreeBSD.org> <201009281220.12278.jkim@FreeBSD.org> <201009281829.13253.jkim@FreeBSD.org> In-Reply-To: <201009281829.13253.jkim@FreeBSD.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, John Baldwin Subject: Re: svn commit: r213241 - in head: include lib/libthr/thread X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Sep 2010 02:42:40 -0000 Jung-uk Kim wrote: > On Tuesday 28 September 2010 12:20 pm, Jung-uk Kim wrote: >> On Tuesday 28 September 2010 12:02 pm, Jung-uk Kim wrote: >>> On Tuesday 28 September 2010 09:31 am, John Baldwin wrote: >>>> On Tuesday, September 28, 2010 12:57:56 am David Xu wrote: >>>>> Author: davidxu >>>>> Date: Tue Sep 28 04:57:56 2010 >>>>> New Revision: 213241 >>>>> URL: http://svn.freebsd.org/changeset/base/213241 >>>>> >>>>> Log: >>>>> In current code, statically initialized and destroyed >>>>> object have same null value, the code can not distinguish >>>>> between them, to fix the problem, now a destroyed object is >>>>> assigned to a non-null value, and it will be rejected by some >>>>> pthread functions. PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP is >>>>> changed to number 1, so that adaptive mutex can be statically >>>>> initialized correctly. >>>> Does this fix PR threads/150889 then? >>> It seems it does. >> Unfortunately, it seems to have a regression: >> >> %cat test.c >> #include >> #include >> >> static pthread_cond_t static_cond = PTHREAD_COND_INITIALIZER; >> static pthread_mutex_t static_mutex = PTHREAD_MUTEX_INITIALIZER; >> >> int >> main(void) >> { >> >> // pthread_mutex_lock(&static_mutex); >> printf("%d\n", pthread_cond_wait(&static_cond, &static_mutex)); >> pthread_mutex_unlock(&static_mutex); >> >> return (0); >> } >> %cc -o test test.c -pthread >> %./test >> Segmentation fault (core dumped) >> >> pthread_cond_wait(3) had to return EPERM here. :-( > > I realized it is a libthr "feature" to catch real application bugs and > to increase performance by not checking rare conditions, I guess. :-/ > > Sorry for the noise, > > Jung-uk Kim > I think your example is legal, I might add checking back, however, it would return two codes, EINVAL and EPERM.