From owner-freebsd-hackers Mon Feb 5 14:23:50 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from karon.dynas.se (karon.dynas.se [192.71.43.4]) by hub.freebsd.org (Postfix) with SMTP id 7163437B401 for ; Mon, 5 Feb 2001 14:23:31 -0800 (PST) Received: (qmail 62862 invoked from network); 5 Feb 2001 22:23:29 -0000 Received: from spirit.sto.dynas.se (HELO spirit.dynas.se) (172.16.1.10) by 172.16.1.1 with SMTP; 5 Feb 2001 22:23:29 -0000 Received: (qmail 7332 invoked from network); 5 Feb 2001 22:23:28 -0000 Received: from explorer.rsa.com (10.81.217.59) by spirit.dynas.se with SMTP; 5 Feb 2001 22:23:28 -0000 Received: (from mikko@localhost) by explorer.rsa.com (8.11.1/8.11.1) id f15MNMI77338; Mon, 5 Feb 2001 14:23:22 -0800 (PST) (envelope-from mikko) Date: Mon, 5 Feb 2001 14:23:22 -0800 (PST) From: Mikko Tyolajarvi Message-Id: <200102052223.f15MNMI77338@explorer.rsa.com> To: pds@uberhacker.org Cc: freebsd-hackers@freebsd.org Subject: Re: known pthread bug? Newsgroups: local.freebsd.hackers References: <20010205005937.M26076@fw.wintelcom.net>; from bright@wintelcom.net on Mon, Feb 05, 2001 at 12:59:37AM -0800 <20010205111506.A73450@uberhacker.org> X-Newsreader: NN version 6.5.6 (NOV) Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In local.freebsd.hackers you write: >On Mon, Feb 05, 2001 at 12:59:37AM -0800, Alfred Perlstein wrote: >> * Paul D. Schmidt [010204 23:23] wrote: >> > Are there currently any known bugs with pthread_mutex_init >> > and pthread_cond_init returning 0, but pthread_cond_wait >> > returning EINVAL nonetheless? >> >> Can you provide a code sample to replicate this and specify which >> version of FreeBSD you're using? >typedef struct cond_tag { > long cond_id; > char *name; > > pthread_mutex_t cond_mutex; > pthread_cond_t sys_cond; >} cond_t; > >void thread_cond_create(cond_t *cond) >{ > pthread_cond_init(&cond->sys_cond, NULL); > pthread_mutex_init(&cond->cond_mutex, NULL); >} > >void thread_cond_wait(cond_t *cond) >{ > pthread_cond_wait(&cond->sys_cond, &cond->cond_mutex); >} >pthread_cond_wait() is returning immediately with EINVAL, even though >printf debugging tells me that both the pthread_(cond|mutex)_init >functions returned 0 (which man tells me is success). This is not a self-contained, runnable example, but if you just call the functions in this order, you will not have not locked the cond_mutex when you read pthread_cond_wait(), which is wrong, since pthread_cond_wait() is supposed to unblock the mutex. $.02, /Mikko -- Mikko Työläjärvi_______________________________________mikko@rsasecurity.com RSA Security To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message