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:
authorCorinna Vinschen <corinna@vinschen.de>2013-05-24 00:10:35 +0400
committerCorinna Vinschen <corinna@vinschen.de>2013-05-24 00:10:35 +0400
commitc6696a3426628761a201c12af68325b12ec6f0b8 (patch)
tree830a7155ce623e0fa95ac94d1b49f99d6fb51279 /winsup/cygwin/dcrt0.cc
parentdf7a7e2e825ce3ca99a1605fed7fd2814568e671 (diff)
* dcrt0.cc (child_info_fork::alloc_stack_hard_way): Fix datatype of
stacksize to SIZE_T. Cast to SIZE_T in pointer arithmetic. Slightly enhance output in case of a fatal error. * fork.cc (frok::parent): Always set ch.stackaddr to DeallocationStack value of current thread to help stack reservation in child_info_fork::alloc_stack_hard_way along. Simplify subsequent code storing stack values in ch. Print guardsize in hex, too.
Diffstat (limited to 'winsup/cygwin/dcrt0.cc')
-rw-r--r--winsup/cygwin/dcrt0.cc17
1 files changed, 10 insertions, 7 deletions
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 0208a9412..d435129d7 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -405,7 +405,7 @@ void
child_info_fork::alloc_stack_hard_way (volatile char *b)
{
void *stack_ptr;
- DWORD stacksize;
+ SIZE_T stacksize;
/* First check if the requested stack area is part of the user heap
or part of a mmapped region. If so, we have been started from a
@@ -415,16 +415,19 @@ child_info_fork::alloc_stack_hard_way (volatile char *b)
&& stackbottom <= cygheap->user_heap.max)
|| is_mmapped_region ((caddr_t) stacktop, (caddr_t) stackbottom))
return;
-
/* First, try to reserve the entire stack. */
- stacksize = (char *) stackbottom - (char *) stackaddr;
+ stacksize = (SIZE_T) stackbottom - (SIZE_T) stackaddr;
if (!VirtualAlloc (stackaddr, stacksize, MEM_RESERVE, PAGE_NOACCESS))
- api_fatal ("fork: can't reserve memory for stack %p - %p, %E",
- stackaddr, stackbottom);
- stacksize = (char *) stackbottom - (char *) stacktop;
+ {
+ PTEB teb = NtCurrentTeb ();
+ api_fatal ("fork: can't reserve memory for parent stack "
+ "%p - %p, (child has %p - %p), %E",
+ stackaddr, stackbottom, teb->DeallocationStack, _tlsbase);
+ }
+ stacksize = (SIZE_T) stackbottom - (SIZE_T) stacktop;
stack_ptr = VirtualAlloc (stacktop, stacksize, MEM_COMMIT, PAGE_READWRITE);
if (!stack_ptr)
- abort ("can't commit memory for stack %p(%d), %E", stacktop, stacksize);
+ abort ("can't commit memory for stack %p(%ly), %E", stacktop, stacksize);
if (guardsize != (size_t) -1)
{
/* Allocate PAGE_GUARD page if it still fits. */