Date: Tue, 28 Sep 2010 23:13:30 -0400 (EDT) From: Daniel Eischen <deischen@freebsd.org> To: David Xu <davidxu@freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, John Baldwin <jhb@freebsd.org>, Jung-uk Kim <jkim@freebsd.org> Subject: Re: svn commit: r213241 - in head: include lib/libthr/thread Message-ID: <Pine.GSO.4.64.1009282307250.2202@sea.ntplx.net> In-Reply-To: <4CA3181E.6030000@freebsd.org> 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>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <pthread.h> >>> #include <stdio.h> >>> >>> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.64.1009282307250.2202>