diff options
author | Kostya Serebryany <kcc@google.com> | 2013-09-12 13:25:29 +0000 |
---|---|---|
committer | Kostya Serebryany <kcc@google.com> | 2013-09-12 13:25:29 +0000 |
commit | 89de457bd3ec40d38bc7860f88f1d4da473eacc4 (patch) | |
tree | 70df3810f4b98bab9f693523935b946323a9195d /lib/asan/lit_tests | |
parent | bdd9545da55933797edf58c6049d894ed0efb465 (diff) | |
download | compiler-rt-89de457bd3ec40d38bc7860f88f1d4da473eacc4.tar.gz compiler-rt-89de457bd3ec40d38bc7860f88f1d4da473eacc4.tar.bz2 compiler-rt-89de457bd3ec40d38bc7860f88f1d4da473eacc4.tar.xz |
[asan] add a test for use-after-return and exceptions and fix it. Not 100% sure this is a complete fix, will keep looking for harder cases.
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@190603 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/asan/lit_tests')
-rw-r--r-- | lib/asan/lit_tests/TestCases/uar_and_exceptions.cc | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/asan/lit_tests/TestCases/uar_and_exceptions.cc b/lib/asan/lit_tests/TestCases/uar_and_exceptions.cc new file mode 100644 index 00000000..f1639f08 --- /dev/null +++ b/lib/asan/lit_tests/TestCases/uar_and_exceptions.cc @@ -0,0 +1,27 @@ +// Test that use-after-return works with exceptions. +// RUN: %clangxx_asan -fsanitize=use-after-return -O0 %s -o %t && %t + +#include <stdio.h> + +volatile char *g; + +void Func(int depth) { + char frame[100]; + g = &frame[0]; + if (depth) + Func(depth - 1); + else + throw 1; +} + +int main(int argc, char **argv) { + for (int i = 0; i < 4000; i++) { + try { + Func(argc * 100); + } catch(...) { + } + if ((i % 1000) == 0) + fprintf(stderr, "done [%d]\n", i); + } + return 0; +} |