Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 1 | // 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 Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 4 | // RUN: env ASAN_OPTIONS=$ASAN_OPTIONS:malloc_context_size=120:redzone=512 not %run %t 2>&1 | FileCheck %s |
Stephen Hines | 6a211c5 | 2014-07-21 00:49:56 -0700 | [diff] [blame] | 5 | // XFAIL: arm-linux-gnueabi |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 6 | // XFAIL: armv7l-unknown-linux-gnueabihf |
Stephen Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 7 | #include <stdlib.h> |
| 8 | #include <stdio.h> |
| 9 | |
| 10 | template <int depth> |
| 11 | struct DeepFree { |
| 12 | static void free(char *x) { |
| 13 | DeepFree<depth - 1>::free(x); |
| 14 | } |
| 15 | }; |
| 16 | |
| 17 | template<> |
| 18 | struct DeepFree<0> { |
| 19 | static void free(char *x) { |
| 20 | ::free(x); |
| 21 | } |
| 22 | }; |
| 23 | |
| 24 | int 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 Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 30 | // 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 Hines | 2d1fdb2 | 2014-05-28 23:58:16 -0700 | [diff] [blame] | 36 | } |