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 4 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 9 10 // Incomplete backtrace on Armv7 11 // UNSUPPORTED: armhf-linux 12 13 #include <stdlib.h> 14 allocate_mem()15__attribute__((noinline)) void *allocate_mem() { return malloc(1); } 16 free_mem(void * ptr)17__attribute__((noinline)) void free_mem(void *ptr) { free(ptr); } 18 touch_mem(void * ptr)19__attribute__((noinline)) void touch_mem(void *ptr) { 20 volatile char sink = *((volatile char *)ptr); 21 } 22 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 29 main()30int main() { 31 for (unsigned i = 0; i < 0x10000; ++i) { 32 void *ptr = allocate_mem(); 33 free_mem(ptr); 34 touch_mem(ptr); 35 } 36 return 0; 37 } 38