[PATCH] D88501: [asan][test] Several Posix/unpoison-alternate-stack.cpp fixes

Rainer Orth via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 30 09:57:40 PDT 2020


This revision was automatically updated to reflect the committed changes.
ro marked an inline comment as done.
Closed by commit rG73fb9698c057: [asan][test] Several Posix/unpoison-alternate-stack.cpp fixes (authored by ro).

Changed prior to commit:
  https://reviews.llvm.org/D88501?vs=294946&id=295335#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88501/new/

https://reviews.llvm.org/D88501

Files:
  compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp


Index: compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp
===================================================================
--- compiler-rt/test/asan/TestCases/Posix/unpoison-alternate-stack.cpp
+++ 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 <algorithm>
 #include <cassert>
 #include <cerrno>
 #include <csetjmp>
@@ -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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88501.295335.patch
Type: text/x-patch
Size: 2092 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200930/0397d4a1/attachment.bin>


More information about the llvm-commits mailing list