1// 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// XFAIL: arm-linux-gnueabi 6#include <stdlib.h> 7#include <stdio.h> 8 9template <int depth> 10struct DeepFree { 11 static void free(char *x) { 12 DeepFree<depth - 1>::free(x); 13 } 14}; 15 16template<> 17struct DeepFree<0> { 18 static void free(char *x) { 19 ::free(x); 20 } 21}; 22 23int main() { 24 char *x = (char*)malloc(10); 25 // deep_free(x); 26 DeepFree<200>::free(x); 27 return x[5]; 28 // CHECK: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}} 29 // CHECK: DeepFree<36> 30 // CHECK: DeepFree<98> 31 // CHECK: DeepFree<115> 32} 33