From owner-svn-src-all@FreeBSD.ORG Wed Sep 29 03:28:03 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 21A08106566B; Wed, 29 Sep 2010 03:28:03 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id C72618FC12; Wed, 29 Sep 2010 03:28:02 +0000 (UTC) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.4/8.14.4/NETPLEX) with ESMTP id o8T3DVFF013361; Tue, 28 Sep 2010 23:13:31 -0400 (EDT) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.2.2 (mail.netplex.net [204.213.176.10]); Tue, 28 Sep 2010 23:13:31 -0400 (EDT) Date: Tue, 28 Sep 2010 23:13:30 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: David Xu In-Reply-To: <4CA3181E.6030000@freebsd.org> Message-ID: References: <201009280457.o8S4vuS9060037@svn.freebsd.org> <201009281202.22555.jkim@FreeBSD.org> <201009281220.12278.jkim@FreeBSD.org> <201009281829.13253.jkim@FreeBSD.org> <4CA3181E.6030000@freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, John Baldwin , Jung-uk Kim 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 Reply-To: Daniel Eischen 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 03:28:03 -0000 On Wed, 29 Sep 2010, David Xu wrote: > Jung-uk Kim wrote: >> On Tuesday 28 September 2010 12:20 pm, Jung-uk Kim wrote: [ snip ] >>> 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. By default, I think we should check. I think PTHREAD_MUTEX_DEFAULT should be equal to PTHREAD_MUTEX_ERRORCHECK. So PTHREAD_MUTEX_INITIALIZER would default to error checking. I also agree -- if the mutex isn't valid, then return EINVAL, and if not locked, return EPERM. -- DE