summaryrefslogtreecommitdiff
path: root/test/asan/TestCases/uar_and_exceptions.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2019-08-05 16:48:12 +0000
committerNico Weber <nicolasweber@gmx.de>2019-08-05 16:48:12 +0000
commit2f91f4f955190c500ab3a1ec4b92ad3f3af72724 (patch)
tree14f3bb241fe04d56481582cad0dcb00f3dc1a01e /test/asan/TestCases/uar_and_exceptions.cpp
parent9b46f1e9a77b1faa2e9869b9b886f05ac5d39411 (diff)
downloadcompiler-rt-2f91f4f955190c500ab3a1ec4b92ad3f3af72724.tar.gz
compiler-rt: Rename cc files below test/asan to cpp
See r367803 and similar other changes. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@367887 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/asan/TestCases/uar_and_exceptions.cpp')
-rw-r--r--test/asan/TestCases/uar_and_exceptions.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/asan/TestCases/uar_and_exceptions.cpp b/test/asan/TestCases/uar_and_exceptions.cpp
new file mode 100644
index 000000000..2357ae803
--- /dev/null
+++ b/test/asan/TestCases/uar_and_exceptions.cpp
@@ -0,0 +1,40 @@
+// Test that use-after-return works with exceptions.
+// RUN: %clangxx_asan -O0 %s -o %t
+// RUN: %env_asan_opts=detect_stack_use_after_return=1 %run %t
+
+#include <stdio.h>
+
+volatile char *g;
+
+#ifndef FRAME_SIZE
+# define FRAME_SIZE 100
+#endif
+
+#ifndef NUM_ITER
+# define NUM_ITER 4000
+#endif
+
+#ifndef DO_THROW
+# define DO_THROW 1
+#endif
+
+void Func(int depth) {
+ char frame[FRAME_SIZE];
+ g = &frame[0];
+ if (depth)
+ Func(depth - 1);
+ else if (DO_THROW)
+ throw 1;
+}
+
+int main(int argc, char **argv) {
+ for (int i = 0; i < NUM_ITER; i++) {
+ try {
+ Func(argc * 100);
+ } catch(...) {
+ }
+ if ((i % (NUM_ITER / 10)) == 0)
+ fprintf(stderr, "done [%d]\n", i);
+ }
+ return 0;
+}