Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion runtime/druntime/src/core/sys/posix/unistd.d
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
26 changes: 25 additions & 1 deletion runtime/druntime/src/etc/linux/memoryerror.d
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down
Loading