brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 4d0c055 Raw
39 lines · cpp
1// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK2// RUN: %clangxx_asan -O1 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK3// RUN: %clangxx_asan -O2 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK4// RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-%os --check-prefix=CHECK5// REQUIRES: stable-runtime6 7#include <stdlib.h>8int main() {9  char * volatile x = new char[10];10  delete[] x;11  return x[5];12  // CHECK: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}}13  // CHECK:   {{0x.* at pc 0x.* bp 0x.* sp 0x.*}}14  // CHECK: {{READ of size 1 at 0x.* thread T0}}15  // CHECK: {{    #0 0x.* in main .*use-after-delete.cpp:}}[[@LINE-4]]16  // CHECK: {{0x.* is located 5 bytes inside of 10-byte region .0x.*,0x.*}}17 18  // CHECK: {{freed by thread T0 here:}}19  // CHECK-Linux:  {{    #0 0x.* in operator delete\[\]}}20  // CHECK-SunOS:  {{    #0 0x.* in operator delete\[\]}}21  // CHECK-Windows:{{    #0 0x.* in operator delete\[\]}}22  // CHECK-FreeBSD:{{    #0 0x.* in operator delete\[\]}}23  // CHECK-Darwin: {{    #0 0x.* in .*_Zda}}24  // CHECK-NEXT:   {{    #1 0x.* in main .*use-after-delete.cpp:}}[[@LINE-14]]25 26  // CHECK: {{previously allocated by thread T0 here:}}27  // CHECK-Linux:  {{    #0 0x.* in operator new\[\]}}28  // CHECK-SunOS:  {{    #0 0x.* in operator new\[\]}}29  // CHECK-Windows:{{    #0 0x.* in operator new\[\]}}30  // CHECK-FreeBSD:{{    #0 0x.* in operator new\[\]}}31  // CHECK-Darwin: {{    #0 0x.* in .*_Zna}}32  // CHECK-NEXT:   {{    #1 0x.* in main .*use-after-delete.cpp:}}[[@LINE-23]]33 34 35  // CHECK: Shadow byte legend (one shadow byte represents {{[0-9]+}} application bytes):36  // CHECK: Global redzone:37  // CHECK: ASan internal:38}39