[llvm-dev] [PATCH compiler-rt 5/5] asan: extend swapcontext_test

Paweł Dziepak via llvm-dev llvm-dev at lists.llvm.org
Tue Feb 2 06:42:43 PST 2016


This patch extends swapcontext_test to verify that the shadow memory
of the stack is properly cleared after throw.
---
 test/asan/TestCases/Linux/swapcontext_test.cc | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/test/asan/TestCases/Linux/swapcontext_test.cc b/test/asan/TestCases/Linux/swapcontext_test.cc
index 86ed593..279566c 100644
--- a/test/asan/TestCases/Linux/swapcontext_test.cc
+++ b/test/asan/TestCases/Linux/swapcontext_test.cc
@@ -17,16 +17,31 @@ ucontext_t child_context;
 
 const int kStackSize = 1 << 20;
 
+volatile int force_write;
+
 __attribute__((noinline))
 void Throw() {
+  char buf[1024];
+  for (int i = 0; i < 1024; i++) {
+    buf[i] = force_write;
+  }
   throw 1;
 }
 
 __attribute__((noinline))
+void Func() {
+  int buf[4 * 1024];
+  for (int i = 0; i < 4 * 1024; i++) {
+    buf[i] = force_write;
+  }
+}
+
+__attribute__((noinline))
 void ThrowAndCatch() {
   try {
     Throw();
   } catch(int a) {
+    Func();
     printf("ThrowAndCatch: %d\n", a);
   }
 }
-- 
2.5.0



More information about the llvm-dev mailing list