diff --git a/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp b/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp --- a/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp +++ b/compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp @@ -7,7 +7,10 @@ // RUN: %run %t // XFAIL: ios && !iossim +// longjmp from signal handler is unportable. +// XFAIL: solaris +#include #include #include #include @@ -83,10 +86,9 @@ void setSignalAlternateStack(void *AltStack) { sigaltstack((stack_t const *)AltStack, nullptr); - struct sigaction Action = { - .sa_sigaction = signalHandler, - .sa_flags = SA_SIGINFO | SA_NODEFER | SA_ONSTACK, - }; + struct sigaction Action = {}; + Action.sa_sigaction = signalHandler; + Action.sa_flags = SA_SIGINFO | SA_NODEFER | SA_ONSTACK; sigemptyset(&Action.sa_mask); sigaction(SIGUSR1, &Action, nullptr); @@ -137,9 +139,11 @@ // reports when the stack is reused. int main() { size_t const PageSize = sysconf(_SC_PAGESIZE); + // The Solaris defaults of 4k (32-bit) and 8k (64-bit) are too small. + size_t const MinStackSize = std::max(PTHREAD_STACK_MIN, 16 * 1024); // To align the alternate stack, we round this up to page_size. size_t const DefaultStackSize = - (PTHREAD_STACK_MIN - 1 + PageSize) & ~(PageSize - 1); + (MinStackSize - 1 + PageSize) & ~(PageSize - 1); // The alternate stack needs a certain size, or the signal handler segfaults. size_t const AltStackSize = 10 * PageSize; size_t const MappingSize = DefaultStackSize + AltStackSize; @@ -149,11 +153,10 @@ MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); - stack_t const AltStack = { - .ss_sp = (char *)Mapping + DefaultStackSize, - .ss_flags = 0, - .ss_size = AltStackSize, - }; + stack_t AltStack = {}; + AltStack.ss_sp = (char *)Mapping + DefaultStackSize; + AltStack.ss_flags = 0; + AltStack.ss_size = AltStackSize; pthread_t Thread; pthread_attr_t ThreadAttr;