public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Iain Buclaw <ibuclaw@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r9-9833] libphobos: Increase size of defaultStackPages on OSX X86_64 targets.
Date: Fri, 19 Nov 2021 14:15:35 +0000 (GMT)	[thread overview]
Message-ID: <20211119141535.BCA893857C6A@sourceware.org> (raw)

https://gcc.gnu.org/g:5e74d1519902df0ccc5573f03e5f2f88efa31890

commit r9-9833-g5e74d1519902df0ccc5573f03e5f2f88efa31890
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Fri Nov 19 14:43:07 2021 +0100

    libphobos: Increase size of defaultStackPages on OSX X86_64 targets.
    
    As of macOS 11, libunwind now requires more stack space than 16k, so
    default to a larger stack size. This is only applied to X86 as the
    PAGESIZE is still 4k, however on AArch64 it is 16k.
    
    libphobos/ChangeLog:
    
            * libdruntime/core/thread.d (defaultStackPages): New constant.
            (Fiber.this): Set stack size to be a multiple of defaultStackPages.
    
    (cherry picked from commit 651a542822d4eea7d6328ad365bb45d1d52acc1e)

Diff:
---
 libphobos/libdruntime/core/thread.d | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/libphobos/libdruntime/core/thread.d b/libphobos/libdruntime/core/thread.d
index 3d2cd287a2e..feac50eb7f2 100644
--- a/libphobos/libdruntime/core/thread.d
+++ b/libphobos/libdruntime/core/thread.d
@@ -4144,6 +4144,24 @@ class Fiber
     // Initialization
     ///////////////////////////////////////////////////////////////////////////
 
+    version (Windows)
+        // exception handling walks the stack, invoking DbgHelp.dll which
+        // needs up to 16k of stack space depending on the version of DbgHelp.dll,
+        // the existence of debug symbols and other conditions. Avoid causing
+        // stack overflows by defaulting to a larger stack size
+        enum defaultStackPages = 8;
+    else version (OSX)
+    {
+        version (X86_64)
+            // libunwind on macOS 11 now requires more stack space than 16k, so
+            // default to a larger stack size. This is only applied to X86 as
+            // the PAGESIZE is still 4k, however on AArch64 it is 16k.
+            enum defaultStackPages = 8;
+        else
+            enum defaultStackPages = 4;
+    }
+    else
+        enum defaultStackPages = 4;
 
     /**
      * Initializes a fiber object which is associated with a static
@@ -4158,7 +4176,7 @@ class Fiber
      * In:
      *  fn must not be null.
      */
-    this( void function() fn, size_t sz = PAGESIZE*4,
+    this( void function() fn, size_t sz = PAGESIZE * defaultStackPages,
           size_t guardPageSize = PAGESIZE ) nothrow
     in
     {
@@ -4184,7 +4202,7 @@ class Fiber
      * In:
      *  dg must not be null.
      */
-    this( void delegate() dg, size_t sz = PAGESIZE*4,
+    this( void delegate() dg, size_t sz = PAGESIZE * defaultStackPages,
           size_t guardPageSize = PAGESIZE ) nothrow
     in
     {


                 reply	other threads:[~2021-11-19 14:15 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=20211119141535.BCA893857C6A@sourceware.org \
    --to=ibuclaw@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.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).