Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / gwp_asan / backtrace.c
blobf4be7305bfb7ef226734de7eacc2e4c09e93a843
1 // REQUIRES: gwp_asan
2 // RUN: %clang_gwp_asan -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer %s -g -o %t
3 // RUN: %expect_crash %t 2>&1 | FileCheck %s
5 // Ensure we don't crash when using the unwinder when frame pointers are
6 // disabled.
7 // RUN: %clang_gwp_asan -fomit-frame-pointer -momit-leaf-frame-pointer %s -g -o %t
8 // RUN: %expect_crash %t
10 // Incomplete backtrace on Armv7
11 // UNSUPPORTED: armhf-linux
13 #include <stdlib.h>
15 __attribute__((noinline)) void *allocate_mem() { return malloc(1); }
17 __attribute__((noinline)) void free_mem(void *ptr) { free(ptr); }
19 __attribute__((noinline)) void touch_mem(void *ptr) {
20 volatile char sink = *((volatile char *)ptr);
23 // CHECK: Use After Free
24 // CHECK: touch_mem
25 // CHECK: was deallocated
26 // CHECK: free_mem
27 // CHECK: was allocated
28 // CHECK: allocate_mem
30 int main() {
31 for (unsigned i = 0; i < 0x10000; ++i) {
32 void *ptr = allocate_mem();
33 free_mem(ptr);
34 touch_mem(ptr);
36 return 0;