Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2003-04-11 06:16:17 +0400
committerChristopher Faylor <me@cgf.cx>2003-04-11 06:16:17 +0400
commit73afb2abb006b84814d2aef1d2119c10b1ad5477 (patch)
tree3a7af81c0e0ea939ced328e7a71a4cb1820de26b /winsup/cygwin/cygthread.cc
parent518a04c40bff988000bfbdecbbec5299e4ac82fc (diff)
* 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.
Diffstat (limited to 'winsup/cygwin/cygthread.cc')
-rw-r--r--winsup/cygwin/cygthread.cc13
1 files changed, 10 insertions, 3 deletions
diff --git a/winsup/cygwin/cygthread.cc b/winsup/cygwin/cygthread.cc
index 1787c415c..967717bfd 100644
--- a/winsup/cygwin/cygthread.cc
+++ b/winsup/cygwin/cygthread.cc
@@ -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;