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
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2015-12-03 14:58:37 +0300
committerCorinna Vinschen <corinna@vinschen.de>2015-12-03 15:28:32 +0300
commit111f32f4ba709be038234fbc7f0254b8f6506564 (patch)
tree10609d8139e05cd90aeb454df46503866e327be3 /winsup
parent600c44512756da11f45bd47b64f9c9cb9b6aa955 (diff)
Always restore full TEB stack info in forkee
* dcrt0.cc (dll_crt0_1): Always restore the TEB stack info. Especially restore DeallocationStack. Fix comment. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog5
-rw-r--r--winsup/cygwin/dcrt0.cc18
2 files changed, 14 insertions, 9 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index e539b896d..03cc4e28b 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,10 @@
2015-12-03 Corinna Vinschen <corinna@vinschen.de>
+ * crt0.cc (dll_crt0_1): Always restore the TEB stack info. Especially
+ restore DeallocationStack. Fix comment.
+
+2015-12-03 Corinna Vinschen <corinna@vinschen.de>
+
* dcrt0.cc (child_info_fork::alloc_stack): Don't set stackaddr to 0.
2015-12-03 Corinna Vinschen <corinna@vinschen.de>
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index ac3360c19..9140fa084 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -910,18 +910,18 @@ dll_crt0_1 (void *)
cygbench ("pre-forkee");
if (in_forkee)
{
- /* If we've played with the stack, stacksize != 0. That means that
- fork() was invoked from other than the main thread. Make sure that
- frame pointer is referencing the new stack so that the OS knows what
- to do when it needs to increase the size of the stack.
+ /* Make sure to restore the TEB's stack info. If guardsize is -1 the
+ stack has been provided by the application and must not be deallocated
+ automagically when the thread exits.
NOTE: Don't do anything that involves the stack until you've completed
this step. */
- if (fork_info->stackaddr)
- {
- NtCurrentTeb()->Tib.StackBase = (PVOID) fork_info->stackbase;
- NtCurrentTeb()->Tib.StackLimit = (PVOID) fork_info->stacklimit;
- }
+ PTEB teb = NtCurrentTeb ();
+ teb->Tib.StackBase = (PVOID) fork_info->stackbase;
+ teb->Tib.StackLimit = (PVOID) fork_info->stacklimit;
+ teb->DeallocationStack = (fork_info->guardsize == (size_t) -1)
+ ? NULL
+ : (PVOID) fork_info->stackaddr;
/* Not resetting _my_tls.incyg here because presumably fork will overwrite
it with the value of the forker and all will be good. */