]> sourceware.org Git - newlib-cygwin.git/commitdiff
* cygthread.cc (cygthread::stub): Initialize stack pointer earlier.
authorChristopher Faylor <me@cgf.cx>
Fri, 11 Apr 2003 02:16:17 +0000 (02:16 +0000)
committerChristopher Faylor <me@cgf.cx>
Fri, 11 Apr 2003 02:16:17 +0000 (02:16 +0000)
(cygthread::simplestub): Initialize stack pointer.
(cygthread::terminate_thread): Account for possibility that stack pointer has
not been set.  Issue warnings for unusual conditions.

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

index e5a1b1ec16671f1e7d6d6c8fc53243b9bb6b9e45..5e9e50619d6d443f43a065792fa5c2e0a91a51ef 100644 (file)
@@ -1,3 +1,10 @@
+2003-04-10  Christopher Faylor  <cgf@redhat.com>
+
+       * cygthread.cc (cygthread::stub): Initialize stack pointer earlier.
+       (cygthread::simplestub): Initialize stack pointer.
+       (cygthread::terminate_thread): Account for possibility that stack
+       pointer has not been set.  Issue warnings for unusual conditions.
+
 2003-04-10  Corinna Vinschen  <corinna@vinschen.de>
 
        * regex/regex.h: Define regoff_t as _off_t.
index 1787c415c3ae5f4db59625cc926365c04494f2ca..967717bfd594c492d822fce36e5de8bda1b5382f 100644 (file)
@@ -50,12 +50,12 @@ cygthread::stub (VOID *arg)
     }
   else
     {
+      info->stack_ptr = &arg;
       if (!info->ev)
        {
          info->ev = CreateEvent (&sec_none_nih, TRUE, FALSE, NULL);
          info->thread_sync = CreateEvent (&sec_none_nih, FALSE, FALSE, NULL);
        }
-      info->stack_ptr = &arg;
     }
   while (1)
     {
@@ -100,6 +100,7 @@ cygthread::simplestub (VOID *arg)
   init_exceptions (&except_entry);
 
   cygthread *info = (cygthread *) arg;
+  info->stack_ptr = &arg;
   info->func (info->arg == cygself ? info : info->arg);
   ExitThread (0);
 }
@@ -175,6 +176,7 @@ cygthread::cygthread (LPTHREAD_START_ROUTINE start, LPVOID param,
     }
   else
     {
+      stack_ptr = NULL;
       h = CreateThread (&sec_none_nih, 0, is_freerange ? simplestub : stub,
                        this, 0, &id);
       if (!h)
@@ -243,13 +245,18 @@ cygthread::terminate_thread ()
   (void) WaitForSingleObject (h, INFINITE);
   CloseHandle (h);
 
+  while (!stack_ptr)
+    low_priority_sleep (0);
 
   MEMORY_BASIC_INFORMATION m;
   memset (&m, 0, sizeof (m));
   (void) VirtualQuery (stack_ptr, &m, sizeof m);
 
-  if (m.RegionSize)
-    (void) VirtualFree (m.AllocationBase, 0, MEM_RELEASE);
+  if (!m.RegionSize)
+    system_printf ("m.RegionSize 0?  stack_ptr %p", stack_ptr);
+  else if (!VirtualFree (m.AllocationBase, 0, MEM_RELEASE))
+    system_printf ("VirtualFree of allocation base %p<%p> failed, %E",
+                  stack_ptr, m.AllocationBase);
 
   h = NULL;
   __name = NULL;
This page took 0.03566 seconds and 5 git commands to generate.