[asan] enable LeakSanitizer (LSan) by default in asan. This only affects Linux x86_64...
[blocksruntime.git] / test / asan / TestCases / uar_and_exceptions.cc
blobc967531c2c02b8da218e890c7a107e3429672b46
1 // Test that use-after-return works with exceptions.
2 // export ASAN_OPTIONS=detect_stack_use_after_return=1
3 // RUN: %clangxx_asan -O0 %s -o %t && %t
5 #include <stdio.h>
7 volatile char *g;
9 #ifndef FRAME_SIZE
10 # define FRAME_SIZE 100
11 #endif
13 #ifndef NUM_ITER
14 # define NUM_ITER 4000
15 #endif
17 #ifndef DO_THROW
18 # define DO_THROW 1
19 #endif
21 void Func(int depth) {
22 char frame[FRAME_SIZE];
23 g = &frame[0];
24 if (depth)
25 Func(depth - 1);
26 else if (DO_THROW)
27 throw 1;
30 int main(int argc, char **argv) {
31 for (int i = 0; i < NUM_ITER; i++) {
32 try {
33 Func(argc * 100);
34 } catch(...) {
36 if ((i % (NUM_ITER / 10)) == 0)
37 fprintf(stderr, "done [%d]\n", i);
39 return 0;