]> sourceware.org Git - newlib-cygwin.git/commitdiff
* pinfo.cc (proc_waiter): Zero wait_thread in child to avoid races with process
authorChristopher Faylor <me@cgf.cx>
Wed, 22 Dec 2004 16:59:03 +0000 (16:59 +0000)
committerChristopher Faylor <me@cgf.cx>
Wed, 22 Dec 2004 16:59:03 +0000 (16:59 +0000)
termination.
* cygthread.cc (cygthread::terminate): Clumsily detect when h has gone away and
attempt no further action.

winsup/cygwin/ChangeLog
winsup/cygwin/cygthread.cc
winsup/cygwin/pinfo.cc

index 88148bf5551da2a305d7ae4e31e9541963a0709f..364f8c398915a503c31db9ddc641e08d5ce693ec 100644 (file)
@@ -1,3 +1,10 @@
+2004-12-22  Christopher Faylor  <cgf@timesys.com>
+
+       * pinfo.cc (proc_waiter): Zero wait_thread in child to avoid races with
+       process termination.
+       * cygthread.cc (cygthread::terminate): Clumsily detect when h has gone away
+       and attempt no further action.
+
 2004-12-22  Christopher Faylor  <cgf@timesys.com>
 
        * cygthread.h (cygthread::release): Just declare here.
index d20bf685321ebd1522712b58d8580a44c8920d01..80fc5e0ccd25b69a11fbdf6827ad6de1280681ba 100644 (file)
@@ -226,18 +226,33 @@ cygthread::release ()
 void
 cygthread::terminate_thread ()
 {
+  /* FIXME: The if (!h) stuff below should be handled better.  The
+     problem is that terminate_thread could be called while a thread
+     is terminating and either the thread could be handling its own
+     release or, if this is being called during exit, some other
+     thread may be attempting to free up this resource.  In the former
+     case, setting some kind of "I deal with my own exit" type of
+     flag may be the way to handle this. */
   if (!is_freerange)
     {
       ResetEvent (*this);
       ResetEvent (thread_sync);
     }
+  if (!h)
+    return;
   (void) TerminateThread (h, 0);
   (void) WaitForSingleObject (h, INFINITE);
+  if (!h)
+    return;
+
   CloseHandle (h);
 
-  while (!stack_ptr)
+  while (h && !stack_ptr)
     low_priority_sleep (0);
 
+  if (!h)
+    return;
+
   MEMORY_BASIC_INFORMATION m;
   memset (&m, 0, sizeof (m));
   (void) VirtualQuery (stack_ptr, &m, sizeof m);
index a26336c986ae342e4417e4601a68450ade2a5553..508ed5cb6596def3ea4e55a1be390e5a5f53e012 100644 (file)
@@ -763,6 +763,7 @@ proc_waiter (void *arg)
     }
 
   sigproc_printf ("exiting wait thread for pid %d", pid);
+  vchild.wait_thread = NULL;
   _my_tls._ctinfo->release (); /* return the cygthread to the cygthread pool */
   return 0;
 }
This page took 0.037174 seconds and 5 git commands to generate.