From 2d80b55b4e58b1c7b1f829809df7864ace82d9dd Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sat, 1 Mar 2008 14:53:44 +0000 Subject: [PATCH] * cygtls.h (_cygtls::handle_threadlist_exception): Eliminate. (_cygtls::init_threadlist_exceptions): Ditto. * cygtls.cc (_cygtls::handle_threadlist_exception): Eliminate. (_cygtls::init_threadlist_exceptions): Ditto. (_cygtls::find_tls): Use myfault handling to deal with errors caused by nonexistent threads. --- winsup/cygwin/ChangeLog | 9 ++++++++ winsup/cygwin/cygtls.cc | 50 ++++++++-------------------------------- winsup/cygwin/cygtls.h | 2 -- winsup/cygwin/sigproc.cc | 1 - 4 files changed, 19 insertions(+), 43 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 0a3ef43bf..3963e0bf5 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +2008-03-01 Christopher Faylor + + * cygtls.h (_cygtls::handle_threadlist_exception): Eliminate. + (_cygtls::init_threadlist_exceptions): Ditto. + * cygtls.cc (_cygtls::handle_threadlist_exception): Eliminate. + (_cygtls::init_threadlist_exceptions): Ditto. + (_cygtls::find_tls): Use myfault handling to deal with errors caused by + nonexistent threads. + 2008-03-01 Christopher Faylor * cygtls.cc (_cygtls::init_exception_handler): Just return. diff --git a/winsup/cygwin/cygtls.cc b/winsup/cygwin/cygtls.cc index 34ba14934..bb6e5a643 100644 --- a/winsup/cygwin/cygtls.cc +++ b/winsup/cygwin/cygtls.cc @@ -195,23 +195,28 @@ _cygtls::push (__stack_t addr) *stackptr++ = (__stack_t) addr; } -#define BAD_IX ((size_t) -1) -static size_t NO_COPY threadlist_ix = BAD_IX; _cygtls * _cygtls::find_tls (int sig) { + static int NO_COPY threadlist_ix; + debug_printf ("sig %d\n", sig); sentry here (INFINITE); - __asm__ volatile (".equ _threadlist_exception_return,."); + _cygtls *res = NULL; - for (threadlist_ix = 0; threadlist_ix < nthreads; threadlist_ix++) + threadlist_ix = -1; + + myfault efault; + if (efault.faulted ()) + cygheap->threadlist[threadlist_ix]->remove (INFINITE); + + while (++threadlist_ix < (int) nthreads) if (sigismember (&(cygheap->threadlist[threadlist_ix]->sigwait_mask), sig)) { res = cygheap->threadlist[threadlist_ix]; break; } - threadlist_ix = BAD_IX; return res; } @@ -221,35 +226,6 @@ _cygtls::set_siginfo (sigpacket *pack) infodata = pack->si; } -extern "C" DWORD __stdcall RtlUnwind (void *, void *, void *, DWORD) __attribute__ ((noreturn)); -int -_cygtls::handle_threadlist_exception (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT *c, void *) -{ - if (e->ExceptionCode != STATUS_ACCESS_VIOLATION) - { - system_printf ("unhandled exception %p at %p", e->ExceptionCode, c->Eip); - return 1; - } - - sentry here; - if (threadlist_ix == BAD_IX) - { - api_fatal ("called with threadlist_ix %d", BAD_IX); - return 1; - } - - if (!here.acquired ()) - { - system_printf ("couldn't aquire muto"); - return 1; - } - - extern void *threadlist_exception_return; - cygheap->threadlist[threadlist_ix]->remove (INFINITE); - threadlist_ix = 0; - return 0; -} - /* Set up the exception handler for the current thread. The x86 uses segment register fs, offset 0 to point to the current exception handler. */ @@ -273,9 +249,3 @@ _cygtls::init_exception_handler (exception_handler *eh) el.prev = _except_list; _except_list = ⪙ } - -void -_cygtls::init_threadlist_exceptions () -{ - init_exception_handler (handle_threadlist_exception); -} diff --git a/winsup/cygwin/cygtls.h b/winsup/cygwin/cygtls.h index 7e584f6fc..14ccffd41 100644 --- a/winsup/cygwin/cygtls.h +++ b/winsup/cygwin/cygtls.h @@ -190,10 +190,8 @@ struct _cygtls /* exception handling */ static int handle_exceptions (EXCEPTION_RECORD *, exception_list *, CONTEXT *, void *); - static int handle_threadlist_exception (EXCEPTION_RECORD *, exception_list *, CONTEXT *, void *); bool inside_kernel (CONTEXT *); void init_exception_handler (int (*) (EXCEPTION_RECORD *, exception_list *, CONTEXT *, void*)); - void init_threadlist_exceptions (); void signal_exit (int) __attribute__ ((noreturn, regparm(2))); void copy_context (CONTEXT *) __attribute__ ((regparm(2))); void signal_debugger (int) __attribute__ ((regparm(2))); diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index a6d8fed17..af2b023d7 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -1166,7 +1166,6 @@ wait_sig (VOID *) SetEvent (wait_sig_inited); _sig_tls = &_my_tls; - _sig_tls->init_threadlist_exceptions (); sigproc_printf ("entering ReadFile loop, my_readsig %p, my_sendsig %p", my_readsig, my_sendsig); -- 2.43.5