Home | History | Annotate | Download | only in Linux
      1 // Check that we detect malloc/delete mismatch only if the approptiate flag
      2 // is set.
      3 
      4 // RUN: %clangxx_asan -g %s -o %t 2>&1
      5 // RUN: ASAN_OPTIONS=alloc_dealloc_mismatch=1 %t 2>&1 | \
      6 // RUN: %symbolize | FileCheck %s
      7 
      8 // No error here.
      9 // RUN: ASAN_OPTIONS=alloc_dealloc_mismatch=0 %t
     10 #include <stdlib.h>
     11 
     12 static volatile char *x;
     13 
     14 int main() {
     15   x = (char*)malloc(10);
     16   x[0] = 0;
     17   delete x;
     18 }
     19 // CHECK: ERROR: AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete) on 0x
     20 // CHECK-NEXT: #0{{.*}}operator delete
     21 // CHECK: #{{.*}}main
     22 // CHECK: is located 0 bytes inside of 10-byte region
     23 // CHECK-NEXT: allocated by thread T0 here:
     24 // CHECK-NEXT: #0{{.*}}malloc
     25 // CHECK: #{{.*}}main
     26 // CHECK: HINT: {{.*}} you may set ASAN_OPTIONS=alloc_dealloc_mismatch=0
     27