blob: 9ce27d5dd6ec346f4756a94e759ca0e66fb7cd2b [file] [log] [blame]
Stephen Hines2d1fdb22014-05-28 23:58:16 -07001// Check that we can store lots of stack frames if asked to.
2
3// RUN: %clangxx_asan -O0 %s -o %t 2>&1
4// RUN: env ASAN_OPTIONS=malloc_context_size=120:redzone=512 not %run %t 2>&1 | FileCheck %s
5#include <stdlib.h>
6#include <stdio.h>
7
8template <int depth>
9struct DeepFree {
10 static void free(char *x) {
11 DeepFree<depth - 1>::free(x);
12 }
13};
14
15template<>
16struct DeepFree<0> {
17 static void free(char *x) {
18 ::free(x);
19 }
20};
21
22int main() {
23 char *x = (char*)malloc(10);
24 // deep_free(x);
25 DeepFree<200>::free(x);
26 return x[5];
27 // CHECK: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}}
28 // CHECK: DeepFree<36>
29 // CHECK: DeepFree<98>
30 // CHECK: DeepFree<115>
31}