diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2011-05-20 07:23:11 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2011-05-20 07:23:11 +0000 |
commit | 89d3c72d510b4e254b38b15865d921d45b26d80a (patch) | |
tree | 8be3d82b93084d305beae6c87019bb8d192e4b44 /winsup/cygwin/init.cc | |
parent | 660302eb67bc951f9a4e543f4b5d02450eea10e2 (diff) | |
download | cygnal-89d3c72d510b4e254b38b15865d921d45b26d80a.tar.gz cygnal-89d3c72d510b4e254b38b15865d921d45b26d80a.tar.bz2 cygnal-89d3c72d510b4e254b38b15865d921d45b26d80a.zip |
* child_info.h (CURR_CHILD_INFO_MAGIC): Update.
(class child_info_fork): Remove stacksize, add stackaddr and guardsize
members.
* dcrt0.cc (child_info_fork::alloc_stack_hard_way): Partial rewrite
to regenerate the stack exactly as in the parent.
(child_info_fork::alloc_stack): Set stackaddr to 0, rather than
stacksize.
(dll_crt0_1): Check for stackaddr before changing the stack addresses
in the TEB.
* fork.cc (frok::child): Check for stackaddr here.
(frok::parent): Set ch.stackaddr and ch.guardsize if not called from
the main thread.
* init.cc (dll_entry): Replace pointer to NT_TIB with pointer to TEB.
Fix incorrectly changed address test before removing _my_tls.
Set StackLimit to NULL on Windows 2000. Explain why.
* miscfuncs.cc (struct thread_wrapper_arg): Store stackbase rather
than stacksize, store commitaddr, remove guardsize. Store all pointers
as char * for easier address arithmetic.
(thread_wrapper): Rewrite to remove OS stack before calling thread
function. Add lots of comments to explain what we do.
(CygwinCreateThread): Reserve our own stack in case we got no
application stack. Add comments.
* ntdll.h (struct _TEB): Extend defintion up to DeallocationStack
member.
* thread.cc (pthread_attr::pthread_attr): Use "(size_t) -1"
rather then 0xffffffff.
* wincap.h (wincaps::has_stack_size_param_is_a_reservation): New
element.
* wincap.cc: Implement above element throughout.
Diffstat (limited to 'winsup/cygwin/init.cc')
-rw-r--r-- | winsup/cygwin/init.cc | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/winsup/cygwin/init.cc b/winsup/cygwin/init.cc index 5404ed15a..9f66c3ba2 100644 --- a/winsup/cygwin/init.cc +++ b/winsup/cygwin/init.cc @@ -115,7 +115,7 @@ extern void __stdcall dll_crt0_0 (); extern "C" BOOL WINAPI dll_entry (HANDLE h, DWORD reason, void *static_load) { - PNT_TIB tib; + PTEB teb; switch (reason) { @@ -131,10 +131,10 @@ dll_entry (HANDLE h, DWORD reason, void *static_load) the auto load address of DLLs? Check if we're running in WOW64 on a 64 bit machine *and* are spawned by a genuine 64 bit process. If so, respawn. */ - tib = &NtCurrentTeb ()->Tib; + teb = NtCurrentTeb (); if (wincap.is_wow64 () - && tib->StackLimit >= (PBOOL) 0x400000 - && tib->StackBase <= (PBOOL) 0x10000000) + && teb->Tib.StackLimit >= (PBOOL) 0x400000 + && teb->Tib.StackBase <= (PBOOL) 0x10000000) respawn_wow64_process (); dll_crt0_0 (); @@ -150,12 +150,19 @@ dll_entry (HANDLE h, DWORD reason, void *static_load) munge_threadfunc (); break; case DLL_THREAD_DETACH: - tib = &NtCurrentTeb ()->Tib; + teb = NtCurrentTeb (); if (dll_finished_loading - && (PVOID) &_my_tls >= tib->StackLimit - && (PVOID) &_my_tls < tib->StackBase + && (PVOID) &teb >= teb->Tib.StackLimit + && (PVOID) &teb < teb->Tib.StackBase && _my_tls.isinitialized ()) _my_tls.remove (0); + /* Windows 2000 has a bug in NtTerminateThread. Instead of releasing + the stack at teb->DeallocationStack it uses the value of + teb->Tib.StackLimit to evaluate the stack address. So we just claim + there is no stack. */ + if (teb->DeallocationStack == NULL + && !wincap.has_stack_size_param_is_a_reservation ()) + teb->Tib.StackLimit = NULL; break; } |