File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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}
677691else version (Darwin)
Original file line number Diff line number Diff line change @@ -50,7 +50,9 @@ import ucontext = core.sys.posix.ucontext;
5050
5151version (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 ;
You can’t perform that action at this time.
0 commit comments