diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2020-04-07 14:09:45 +0200 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2020-04-07 14:18:08 +0200 |
commit | aa4d9603069503207e399b6240d12b46a8df6414 (patch) | |
tree | 2b1b44afcd9dc138c33341e1037692f46d6adddc | |
parent | ece49e4090564e7ac7b936692e15a78e1a3cb39c (diff) | |
download | cygnal-aa4d9603069503207e399b6240d12b46a8df6414.tar.gz cygnal-aa4d9603069503207e399b6240d12b46a8df6414.tar.bz2 cygnal-aa4d9603069503207e399b6240d12b46a8df6414.zip |
Cygwin: threads: use mmap area to fulfill requests for big stacks
Otherwise big stacks have a higher probability to collide with
randomized PEBs and TEBs after fork.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
-rw-r--r-- | winsup/cygwin/miscfuncs.cc | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc index 1ed9684f1..e1eb5e8e2 100644 --- a/winsup/cygwin/miscfuncs.cc +++ b/winsup/cygwin/miscfuncs.cc @@ -515,11 +515,13 @@ public: BOOL overflow = FALSE; PVOID real_stackaddr = NULL; - /* If an application requests a monster stack, we fulfill this request - from outside of our pool, top down. */ + /* If an application requests a monster stack, fulfill request + from mmap area. */ if (real_size > THREAD_STACK_MAX) - return VirtualAlloc (NULL, real_size, MEM_RESERVE | MEM_TOP_DOWN, - PAGE_READWRITE); + { + PVOID addr = mmap_alloc.alloc (NULL, real_size, false); + return VirtualAlloc (addr, real_size, MEM_RESERVE, PAGE_READWRITE); + } /* Simple round-robin. Keep looping until VirtualAlloc succeeded, or until we overflowed and hit the current address. */ for (UINT_PTR addr = current - real_size; |