brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · e75bc48 Raw
28 lines · cpp
1// RUN: %clangxx_asan -O0 %s -o %t2// RUN: %env_asan_opts=malloc_context_size=0:fast_unwind_on_malloc=0 not %run %t 2>&1 | FileCheck %s3// RUN: %env_asan_opts=malloc_context_size=0:fast_unwind_on_malloc=1 not %run %t 2>&1 | FileCheck %s4// RUN: %env_asan_opts=malloc_context_size=1:fast_unwind_on_malloc=0 not %run %t 2>&1 | FileCheck %s5// RUN: %env_asan_opts=malloc_context_size=1:fast_unwind_on_malloc=1 not %run %t 2>&1 | FileCheck %s6// RUN: %env_asan_opts=malloc_context_size=2 not %run %t 2>&1 | FileCheck %s --check-prefix=TWO7 8int main() {9  char *x = new char[20];10  delete[] x;11  return x[0];12 13  // CHECK: freed by thread T{{.*}} here:14  // CHECK-NEXT: #0 0x{{.*}} in {{operator delete( )?\[\]|_ZdaPv}}15  // CHECK-NOT: #1 0x{{.*}}16 17  // CHECK: previously allocated by thread T{{.*}} here:18  // CHECK-NEXT: #0 0x{{.*}} in {{operator new( )?\[\]|_Znam}}19  // CHECK-NOT: #1 0x{{.*}}20 21  // CHECK: SUMMARY: AddressSanitizer: heap-use-after-free22 23  // TWO: previously allocated by thread T{{.*}} here:24  // TWO-NEXT: #0 0x{{.*}}25  // TWO-NEXT: #1 0x{{.*}} in main {{.*}}malloc_context_size.cpp26  // TWO: SUMMARY: AddressSanitizer: heap-use-after-free27}28