[OptTable] Fix typo VALUE => VALUES (NFCI) (#121523)
[llvm-project.git] / compiler-rt / test / asan / TestCases / deep_stack_uaf.cpp
blob7d8a09220689f5cf6b20b1b827e2e1db97178562
1 // Check that we can store lots of stack frames if asked to.
3 // RUN: %clangxx_asan -O0 %s -o %t 2>&1
4 // RUN: %env_asan_opts=malloc_context_size=125:redzone=512 not %run %t 2>&1 | FileCheck %s
5 // REQUIRES: stable-runtime
6 #include <stdlib.h>
7 #include <stdio.h>
9 template <int depth>
10 struct DeepFree {
11 static void free(char *x) {
12 DeepFree<depth - 1>::free(x);
16 template<>
17 struct DeepFree<0> {
18 static void free(char *x) {
19 ::free(x);
23 int 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 // The libcxxrt demangling procedure on FreeBSD 9.2 incorrectly appends
30 // extra 'E' characters to the end of template arguments; see:
31 // https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=192115
32 // CHECK: {{DeepFree<36>|DeepFree<36E>}}
33 // CHECK: {{DeepFree<98>|DeepFree<98E>}}
34 // CHECK: {{DeepFree<115>|DeepFree<115E>}}