+2008-03-01 Christopher Faylor <me+cygwin@cgf.cx>
+
+ * 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 <me+cygwin@cgf.cx>
* cygtls.cc (_cygtls::init_exception_handler): Just return.
*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;
}
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. */
el.prev = _except_list;
_except_list = ⪙
}
-
-void
-_cygtls::init_threadlist_exceptions ()
-{
- init_exception_handler (handle_threadlist_exception);
-}
/* 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)));