From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1873) id 545D4385AC0A; Fri, 19 Nov 2021 14:14:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 545D4385AC0A MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Iain Buclaw To: gcc-cvs@gcc.gnu.org Subject: [gcc r10-10282] libphobos: Increase size of defaultStackPages on OSX X86_64 targets. X-Act-Checkin: gcc X-Git-Author: Iain Buclaw X-Git-Refname: refs/heads/releases/gcc-10 X-Git-Oldrev: 910d2b4b7513b6bfe02777d44cd5377c22198086 X-Git-Newrev: 651a542822d4eea7d6328ad365bb45d1d52acc1e Message-Id: <20211119141413.545D4385AC0A@sourceware.org> Date: Fri, 19 Nov 2021 14:14:13 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Nov 2021 14:14:13 -0000 https://gcc.gnu.org/g:651a542822d4eea7d6328ad365bb45d1d52acc1e commit r10-10282-g651a542822d4eea7d6328ad365bb45d1d52acc1e Author: Iain Buclaw 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 f316727e5f6a4c58b63bdee9ad6be785f97f5ee7) 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 e1a68057ca1..79cd40c6fdd 100644 --- a/libphobos/libdruntime/core/thread.d +++ b/libphobos/libdruntime/core/thread.d @@ -4146,6 +4146,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 @@ -4160,7 +4178,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 { @@ -4186,7 +4204,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 {