Skip to content

Commit 7928c3d

Browse files
committed
[test]
1 parent f39ce8b commit 7928c3d

2 files changed

Lines changed: 31 additions & 4 deletions

File tree

runtime/druntime/src/core/sys/posix/unistd.d

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,21 @@ version (CRuntime_Glibc)
671671
_SC_LEVEL4_CACHE_LINESIZE,
672672

673673
_SC_IPV6 = _SC_LEVEL1_ICACHE_SIZE + 50,
674-
_SC_RAW_SOCKETS
674+
_SC_RAW_SOCKETS,
675+
_SC_V7_ILP32_OFF32,
676+
_SC_V7_ILP32_OFFBIG,
677+
_SC_V7_LP64_OFF64,
678+
_SC_V7_LPBIG_OFFBIG,
679+
_SC_SS_REPL_MAX,
680+
_SC_TRACE_EVENT_NAME_MAX,
681+
_SC_TRACE_NAME_MAX,
682+
_SC_TRACE_SYS_MAX,
683+
_SC_TRACE_USER_EVENT_MAX,
684+
_SC_XOPEN_STREAMS,
685+
_SC_THREAD_ROBUST_PRIO_INHERIT,
686+
_SC_THREAD_ROBUST_PRIO_PROTECT,
687+
_SC_MINSIGSTKSZ,
688+
_SC_SIGSTKSZ,
675689
}
676690
}
677691
else version (Darwin)

runtime/druntime/src/etc/linux/memoryerror.d

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ import ucontext = core.sys.posix.ucontext;
5050

5151
version (MemoryAssertSupported)
5252
{
53+
import core.stdc.stdlib : malloc;
5354
import core.sys.posix.signal : SA_ONSTACK, sigaltstack, SIGSTKSZ, stack_t;
55+
import core.sys.posix.unistd : sysconf, _SC_SIGSTKSZ;
5456
}
5557

5658
@system:
@@ -423,10 +425,21 @@ version (MemoryAssertSupported)
423425

424426
// Set up alternate stack, because segfaults can be caused by stack overflow,
425427
// in which case the stack is already exhausted
426-
__gshared ubyte[SIGSTKSZ] altStack;
428+
auto altStackSize = sysconf(_SC_SIGSTKSZ);
429+
if (altStackSize <= 0)
430+
altStackSize = SIGSTKSZ;
431+
432+
__gshared void* altStack; // only allocate once; never free'd
433+
if (!altStack)
434+
{
435+
altStack = malloc(altStackSize);
436+
if (!altStack)
437+
return false;
438+
}
439+
427440
stack_t ss;
428-
ss.ss_sp = altStack.ptr;
429-
ss.ss_size = altStack.length;
441+
ss.ss_sp = altStack;
442+
ss.ss_size = altStackSize;
430443
ss.ss_flags = 0;
431444
if (sigaltstack(&ss, null) == -1)
432445
return false;

0 commit comments

Comments
 (0)