* cygheap.cc (init_cygheap::find_tls): Allow to keep loop going after

access to threadlist[ix] faulted.  In case of an exception, remove
	threadlist[ix] from threadlist only.  Add comment.
This commit is contained in:
Corinna Vinschen 2014-11-27 16:20:14 +00:00
parent 84b2a020da
commit db880b5642
2 changed files with 33 additions and 19 deletions

View File

@ -1,3 +1,9 @@
2014-11-27 Corinna Vinschen <corinna@vinschen.de>
* cygheap.cc (init_cygheap::find_tls): Allow to keep loop going after
access to threadlist[ix] faulted. In case of an exception, remove
threadlist[ix] from threadlist only. Add comment.
2014-11-26 Corinna Vinschen <corinna@vinschen.de> 2014-11-26 Corinna Vinschen <corinna@vinschen.de>
* Makefile.in (install): Add install-ldif target. * Makefile.in (install): Add install-ldif target.

View File

@ -667,26 +667,34 @@ init_cygheap::find_tls (int sig, bool& issig_wait)
_cygtls *t = NULL; _cygtls *t = NULL;
issig_wait = false; issig_wait = false;
__try ix = -1;
/* Scan thread list looking for valid signal-delivery candidates */
while (++ix < (int) nthreads)
{ {
ix = -1; __try
/* Scan thread list looking for valid signal-delivery candidates */ {
while (++ix < (int) nthreads) if (!threadlist[ix]->tid)
if (!threadlist[ix]->tid) continue;
continue; else if (sigismember (&(threadlist[ix]->sigwait_mask), sig))
else if (sigismember (&(threadlist[ix]->sigwait_mask), sig)) {
{ t = cygheap->threadlist[ix];
t = cygheap->threadlist[ix]; issig_wait = true;
issig_wait = true; __leave;
__leave; }
} else if (!t && !sigismember (&(threadlist[ix]->sigmask), sig))
else if (!t && !sigismember (&(threadlist[ix]->sigmask), sig)) t = cygheap->threadlist[ix];
t = cygheap->threadlist[ix]; }
__except (NO_ERROR)
{
/* We're here because threadlist[ix] became NULL or invalid. In
theory this should be impossible due to correct synchronization.
But *if* it happens, just remove threadlist[ix] from threadlist.
TODO: This should be totally unnecessary. */
debug_printf ("cygtls synchronization is leaking...");
remove_tls (threadlist[ix], 0);
--ix;
}
__endtry
} }
__except (NO_ERROR)
{
threadlist[ix]->remove (INFINITE);
}
__endtry
return t; return t;
} }