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
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.
-rw-r--r--winsup/cygwin/ChangeLog10
-rw-r--r--winsup/cygwin/dcrt0.cc17
-rw-r--r--winsup/cygwin/fork.cc18
3 files changed, 27 insertions, 18 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index e91432d3e..89490e036 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,15 @@
2013-05-23 Corinna Vinschen <corinna@vinschen.de>
+ * 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.
+
+2013-05-23 Corinna Vinschen <corinna@vinschen.de>
+
* environ.cc (set_winsymlinks): Handle "winsymlinks:nativestrict"
option. On pre-Vista warn the user if the "winsymlinks:native*" option
is set.
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. */
diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc
index 634621351..7d5f7101c 100644
--- a/winsup/cygwin/fork.cc
+++ b/winsup/cygwin/fork.cc
@@ -302,17 +302,17 @@ frok::parent (volatile char * volatile stack_here)
ch.forker_finished = forker_finished;
+ PTEB teb = NtCurrentTeb ();
ch.stackbottom = _tlsbase;
ch.stacktop = (void *) _tlstop;
- ch.stackaddr = 0;
+ ch.stackaddr = teb->DeallocationStack;
ch.guardsize = 0;
if (&_my_tls != _main_tls)
{
/* We have not been started from the main thread. Fetch the
information required to set up the thread stack identically
in the child. */
- PTEB teb = NtCurrentTeb ();
- if (!teb->DeallocationStack)
+ if (!ch.stackaddr)
{
/* Pthread with application-provided stack. Don't set up a
PAGE_GUARD page. guardsize == -1 is used in alloc_stack_hard_way
@@ -320,15 +320,11 @@ frok::parent (volatile char * volatile stack_here)
ch.stackaddr = _my_tls.tid->attr.stackaddr;
ch.guardsize = (size_t) -1;
}
- else
- {
- ch.stackaddr = teb->DeallocationStack;
- /* If it's a pthread, fetch guardsize from thread attributes. */
- if (_my_tls.tid)
- ch.guardsize = _my_tls.tid->attr.guardsize;
- }
+ else if (_my_tls.tid)
+ /* If it's a pthread, fetch guardsize from thread attributes. */
+ ch.guardsize = _my_tls.tid->attr.guardsize;
}
- debug_printf ("stack - bottom %p, top %p, addr %p, guardsize %lu",
+ debug_printf ("stack - bottom %p, top %p, addr %p, guardsize %ly",
ch.stackbottom, ch.stacktop, ch.stackaddr, ch.guardsize);
PROCESS_INFORMATION pi;