summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/dcrt0.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/dcrt0.cc')
-rw-r--r--winsup/cygwin/dcrt0.cc9
1 files changed, 9 insertions, 0 deletions
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 92056c80f..a6eb2696d 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -398,6 +398,15 @@ child_info_fork::alloc_stack_hard_way (volatile char *b)
int newlen;
bool guard;
+ /* First check if the requested stack area is part of the user heap
+ or part of a mmaped region. If so, we have been started from a
+ pthread with an application-provided stack, and the stack has just
+ to be used as is. */
+ if ((stacktop >= cygheap->user_heap.base
+ && stackbottom <= cygheap->user_heap.max)
+ || is_mmapped_region ((caddr_t) stacktop, (caddr_t) stackbottom))
+ return;
+
if (!VirtualQuery ((LPCVOID) &b, &m, sizeof m))
api_fatal ("fork: couldn't get stack info, %E");