diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2015-01-07 19:55:37 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2015-01-07 19:55:37 +0000 |
commit | ca9211ecdede9bdedb812b2243a4abdb8dacd1b9 (patch) | |
tree | 9b19e801150082c33e9152275829a6ce90614b55 /test/asan/TestCases/uar_and_exceptions.cc | |
parent | 8ef50bf3d1c287b5013c3168de77a462dfce3495 (diff) |
Notes
Diffstat (limited to 'test/asan/TestCases/uar_and_exceptions.cc')
-rw-r--r-- | test/asan/TestCases/uar_and_exceptions.cc | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/asan/TestCases/uar_and_exceptions.cc b/test/asan/TestCases/uar_and_exceptions.cc new file mode 100644 index 0000000000000..0bfe297295553 --- /dev/null +++ b/test/asan/TestCases/uar_and_exceptions.cc @@ -0,0 +1,43 @@ +// Test that use-after-return works with exceptions. +// export ASAN_OPTIONS=detect_stack_use_after_return=1 +// RUN: %clangxx_asan -O0 %s -o %t && %run %t + +// Clang doesn't support exceptions on Windows yet. +// XFAIL: win32 + +#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; +} |