brintos

brintos / llvm-project-archived public Read only

0
0
Text · 960 B · f4be730 Raw
38 lines · c
1// REQUIRES: gwp_asan2// RUN: %clang_gwp_asan -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer %s -g -o %t3// RUN: %expect_crash %t 2>&1 | FileCheck %s4 5// Ensure we don't crash when using the unwinder when frame pointers are6// disabled.7// RUN: %clang_gwp_asan -fomit-frame-pointer -momit-leaf-frame-pointer %s -g -o %t8// RUN: %expect_crash %t9 10// Incomplete backtrace on Armv711// UNSUPPORTED: armhf-linux12 13#include <stdlib.h>14 15__attribute__((noinline)) void *allocate_mem() { return malloc(1); }16 17__attribute__((noinline)) void free_mem(void *ptr) { free(ptr); }18 19__attribute__((noinline)) void touch_mem(void *ptr) {20  volatile char sink = *((volatile char *)ptr);21}22 23// CHECK: Use After Free24// CHECK: touch_mem25// CHECK: was deallocated26// CHECK: free_mem27// CHECK: was allocated28// CHECK: allocate_mem29 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