From owner-freebsd-stable Wed May 1 11: 0:12 2002 Delivered-To: freebsd-stable@freebsd.org Received: from InterJet.dellroad.org (adsl-63-194-81-26.dsl.snfc21.pacbell.net [63.194.81.26]) by hub.freebsd.org (Postfix) with ESMTP id 04B5737B416 for ; Wed, 1 May 2002 11:00:03 -0700 (PDT) Received: from arch20m.dellroad.org (arch20m.dellroad.org [10.1.1.20]) by InterJet.dellroad.org (8.9.1a/8.9.1) with ESMTP id KAA69856; Wed, 1 May 2002 10:49:37 -0700 (PDT) Received: (from archie@localhost) by arch20m.dellroad.org (8.11.6/8.11.6) id g41Hnbs92444; Wed, 1 May 2002 10:49:37 -0700 (PDT) (envelope-from archie) From: Archie Cobbs Message-Id: <200205011749.g41Hnbs92444@arch20m.dellroad.org> Subject: Re: Bug in pthread_cancel() In-Reply-To: <200205011559.g41Fx4Z92027@arch20m.dellroad.org> "from Archie Cobbs at May 1, 2002 08:59:04 am" To: eischen@pcnet1.pcnet.com Date: Wed, 1 May 2002 10:49:37 -0700 (PDT) Cc: "Jeroen Ruigrok/asmodai" , freebsd-stable@FreeBSD.ORG X-Mailer: ELM [version 2.4ME+ PL88 (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII Sender: owner-freebsd-stable@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Archie Cobbs writes: > > >Hmm, what about just bypassing the pthread_cancel() if the > > >thread is already in the process of exiting? > > I didn't include a test case but I'll give your patch a try later today. Daniel- Your patch does not fix the problem. The call to pthread_cancel() happens before the thread starts to exit. Since the thread has deferred cancellation, it does not take effect immediately. The thread does not invoke a cancellation point until later during the execution of a cleanup hook. So I suppose another fix might be to clear the PTHREAD_CANCELLING flag when pthread_exit() is called... though I don't see how to avoid the race condition there between clearing that flag and some other thread calling pthread_cancel() later (pthread_exit() does not disable context switches while executing the cleanups). So I stand by my original patch :-) In the mean time I'll try to come up with a simple test case. Thanks, -Archie __________________________________________________________________________ Archie Cobbs * Packet Design * http://www.packetdesign.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-stable" in the body of the message