diff --git a/runtime/druntime/src/core/sys/posix/unistd.d b/runtime/druntime/src/core/sys/posix/unistd.d index 860630b4225..83536a30401 100644 --- a/runtime/druntime/src/core/sys/posix/unistd.d +++ b/runtime/druntime/src/core/sys/posix/unistd.d @@ -671,7 +671,21 @@ version (CRuntime_Glibc) _SC_LEVEL4_CACHE_LINESIZE, _SC_IPV6 = _SC_LEVEL1_ICACHE_SIZE + 50, - _SC_RAW_SOCKETS + _SC_RAW_SOCKETS, + _SC_V7_ILP32_OFF32, + _SC_V7_ILP32_OFFBIG, + _SC_V7_LP64_OFF64, + _SC_V7_LPBIG_OFFBIG, + _SC_SS_REPL_MAX, + _SC_TRACE_EVENT_NAME_MAX, + _SC_TRACE_NAME_MAX, + _SC_TRACE_SYS_MAX, + _SC_TRACE_USER_EVENT_MAX, + _SC_XOPEN_STREAMS, + _SC_THREAD_ROBUST_PRIO_INHERIT, + _SC_THREAD_ROBUST_PRIO_PROTECT, + _SC_MINSIGSTKSZ, + _SC_SIGSTKSZ, } } else version (Darwin) diff --git a/runtime/druntime/src/etc/linux/memoryerror.d b/runtime/druntime/src/etc/linux/memoryerror.d index b44a7f6d68f..b97bb7948f0 100644 --- a/runtime/druntime/src/etc/linux/memoryerror.d +++ b/runtime/druntime/src/etc/linux/memoryerror.d @@ -50,6 +50,7 @@ import ucontext = core.sys.posix.ucontext; version (MemoryAssertSupported) { + import core.stdc.stdlib : malloc; import core.sys.posix.signal : SA_ONSTACK, sigaltstack, SIGSTKSZ, stack_t; } @@ -423,7 +424,30 @@ version (MemoryAssertSupported) // Set up alternate stack, because segfaults can be caused by stack overflow, // in which case the stack is already exhausted - __gshared ubyte[SIGSTKSZ] altStack; + + __gshared void[] altStack; // lazily allocated once only via malloc; never free'd + if (altStack.ptr is null) + { + version (CRuntime_Glibc) + { + // glibc v2.34 switched to a dynamic SIGSTKSZ + import core.sys.posix.unistd : sysconf, _SC_SIGSTKSZ; + + auto size = sysconf(_SC_SIGSTKSZ); + if (size <= 0) + size = SIGSTKSZ; + } + else + { + const size = SIGSTKSZ; + } + + if (auto p = malloc(size)) + altStack = p[0 .. size]; + else + return false; + } + stack_t ss; ss.ss_sp = altStack.ptr; ss.ss_size = altStack.length;