From owner-freebsd-hackers Tue Dec 4 4:26:41 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from pcnet1.pcnet.com (pcnet1.pcnet.com [204.213.232.3]) by hub.freebsd.org (Postfix) with ESMTP id E834337B419; Tue, 4 Dec 2001 04:26:26 -0800 (PST) Received: from vigrid.com (pm3-pt10.pcnet.net [206.105.29.84]) by pcnet1.pcnet.com (8.12.1/8.12.1) with ESMTP id fB4CPJ3a017219; Tue, 4 Dec 2001 07:25:20 -0500 (EST) Message-ID: <3C0CC2FE.275F4C68@vigrid.com> Date: Tue, 04 Dec 2001 07:35:10 -0500 From: Dan Eischen X-Mailer: Mozilla 4.5 [en] (X11; I; FreeBSD 5.0-CURRENT i386) X-Accept-Language: en MIME-Version: 1.0 To: Alfred Perlstein Cc: Louis-Philippe Gagnon , freebsd-current@FreeBSD.ORG, freebsd-hackers@FreeBSD.ORG Subject: Re: Possible libc_r pthread bug References: <094601c179ea$7cca85c0$2964a8c0@MACADAMIAN.com> <20011204021815.E92148@elvis.mu.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Alfred Perlstein wrote: > > * Daniel Eischen [011130 16:17] wrote: > > On Fri, 30 Nov 2001, Louis-Philippe Gagnon wrote: > > > If at first you don't succeed... > > > > > > I've encountered a problem using pthread_cancel, pthread_join and > > > pthread_setcanceltype, I'm hoping someone can shed some light. > > > > > > (in a nutshell : pthread_setcanceltype doesn't seem to work in FreeBSD 4.4) > > > > > > (posted to -current and -hackers; if there's a more appropriate mailing list > > > for this, please let me know) > > > > > > I recently encountered a situation where, after calling pthread_cancel to > > > cancel a thread, the call to pthread_join hangs indefinitely. I quickly figured > > > out that it was because the thread being cancelled was never reaching a > > > cancellation point (in fact it was an infinite loop with no function calls at all). > > > Sure enough, adding a pthread_testcancel() in the loop allowed > > > pthread_join to return. However this solution isn't acceptable for my requirements. > > please test the following patch: There are already cancellation tests when resuming threads whose contexts are not saved as a result of a signal interrupt (ctxtype != CTX_UC). You shouldn't test for cancellation when ctxtype == CTX_UC because you are running on the scheduler stack, not the threads stack. You also have a bug in the way you changed the check for cancellation flags. There only clean way to fix this is to add a return frame to the interrupted context so that it can check for cancellation (and other things) before returning to the threads interrupted context. -- Dan Eischen To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message