diff options
author | Christopher Faylor <me@cgf.cx> | 2003-04-11 02:16:17 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2003-04-11 02:16:17 +0000 |
commit | 73afb2abb006b84814d2aef1d2119c10b1ad5477 (patch) | |
tree | 3a7af81c0e0ea939ced328e7a71a4cb1820de26b | |
parent | 518a04c40bff988000bfbdecbbec5299e4ac82fc (diff) | |
download | newlib-73afb2abb006b84814d2aef1d2119c10b1ad5477.zip newlib-73afb2abb006b84814d2aef1d2119c10b1ad5477.tar.gz newlib-73afb2abb006b84814d2aef1d2119c10b1ad5477.tar.bz2 |
* 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.
-rw-r--r-- | winsup/cygwin/ChangeLog | 7 | ||||
-rw-r--r-- | winsup/cygwin/cygthread.cc | 13 |
2 files changed, 17 insertions, 3 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index e5a1b1e..5e9e506 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -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. diff --git a/winsup/cygwin/cygthread.cc b/winsup/cygwin/cygthread.cc index 1787c41..967717b 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; |