Date: Tue, 04 Dec 2001 07:35:10 -0500 From: Dan Eischen <eischen@vigrid.com> To: Alfred Perlstein <bright@mu.org> Cc: Louis-Philippe Gagnon <louisphilippe@macadamian.com>, freebsd-current@FreeBSD.ORG, freebsd-hackers@FreeBSD.ORG Subject: Re: Possible libc_r pthread bug Message-ID: <3C0CC2FE.275F4C68@vigrid.com> References: <094601c179ea$7cca85c0$2964a8c0@MACADAMIAN.com> <Pine.SUN.3.91.1011130170847.14642A-100000@pcnet1.pcnet.com> <20011204021815.E92148@elvis.mu.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Alfred Perlstein wrote: > > * Daniel Eischen <eischen@pcnet1.pcnet.com> [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-current" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3C0CC2FE.275F4C68>