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 not %t 2>&1 | FileCheck %s
      6 
      7 // No error here.
      8 // RUN: ASAN_OPTIONS=alloc_dealloc_mismatch=0 %t
      9 #include <stdlib.h>
     10 
     11 static volatile char *x;
     12 
     13 int main() {
     14   x = (char*)malloc(10);
     15   x[0] = 0;
     16   delete x;
     17 }
     18 // CHECK: ERROR: AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete) on 0x
     19 // CHECK-NEXT: #0{{.*}}operator delete
     20 // CHECK: #{{.*}}main
     21 // CHECK: is located 0 bytes inside of 10-byte region
     22 // CHECK-NEXT: allocated by thread T0 here:
     23 // CHECK-NEXT: #0{{.*}}malloc
     24 // CHECK: #{{.*}}main
     25 // CHECK: HINT: {{.*}} you may set ASAN_OPTIONS=alloc_dealloc_mismatch=0
     26