public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: threads: use mmap area to fulfill requests for big stacks
Date: Tue,  7 Apr 2020 12:18:23 +0000 (GMT)	[thread overview]
Message-ID: <20200407121823.193D6385BF83@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=aa4d9603069503207e399b6240d12b46a8df6414

commit aa4d9603069503207e399b6240d12b46a8df6414
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Tue Apr 7 14:09:45 2020 +0200

    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>

Diff:
---
 winsup/cygwin/miscfuncs.cc | 10 ++++++----
 1 file 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;


                 reply	other threads:[~2020-04-07 12:18 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200407121823.193D6385BF83@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).