blob: 95032f2bd4f5513e64137528ebb2257700d3aba7 [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
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -08004// RUN: %env_asan_opts=malloc_context_size=120:redzone=512 not %run %t 2>&1 | FileCheck %s
Stephen Hines6a211c52014-07-21 00:49:56 -07005// XFAIL: arm-linux-gnueabi
Stephen Hines6d186232014-11-26 17:56:19 -08006// XFAIL: armv7l-unknown-linux-gnueabihf
Stephen Hines2d1fdb22014-05-28 23:58:16 -07007#include <stdlib.h>
8#include <stdio.h>
9
10template <int depth>
11struct DeepFree {
12 static void free(char *x) {
13 DeepFree<depth - 1>::free(x);
14 }
15};
16
17template<>
18struct DeepFree<0> {
19 static void free(char *x) {
20 ::free(x);
21 }
22};
23
24int main() {
25 char *x = (char*)malloc(10);
26 // deep_free(x);
27 DeepFree<200>::free(x);
28 return x[5];
29 // CHECK: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}}
Stephen Hines6d186232014-11-26 17:56:19 -080030 // The libcxxrt demangling procedure on FreeBSD 9.2 incorrectly appends
31 // extra 'E' characters to the end of template arguments; see:
32 // https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=192115
33 // CHECK: {{DeepFree<36>|DeepFree<36E>}}
34 // CHECK: {{DeepFree<98>|DeepFree<98E>}}
35 // CHECK: {{DeepFree<115>|DeepFree<115E>}}
Stephen Hines2d1fdb22014-05-28 23:58:16 -070036}