1 // RUN: %clangxx_asan -O0 %s --std=c++14 -o %t
3 // RUN: not %run %t 10 0 2>&1 | FileCheck %s --check-prefixes=CHECK,T0
4 // RUN: not %run %t 10000000 0 2>&1 | FileCheck %s --check-prefixes=CHECK,T0
6 // RUN: not %run %t 10 1 2>&1 | FileCheck %s --check-prefixes=CHECK,T1
7 // RUN: not %run %t 10000000 1 2>&1 | FileCheck %s --check-prefixes=CHECK,T1
9 // REQUIRES: stable-runtime
11 #include <sanitizer/asan_interface.h>
15 void UPDATE(void *p
) {
16 __asan_update_allocation_context(p
);
19 int main(int argc
, char *argv
[]) {
20 char *x
= (char *)malloc(atoi(argv
[1]) * sizeof(char));
22 std::thread([&]() { UPDATE(x
); }).join();
27 // CHECK: {{.*ERROR: AddressSanitizer: heap-use-after-free on address}}
28 // CHECK: READ of size 1 at {{.*}} thread T0
29 // T0: allocated by thread T0 here
30 // T1: allocated by thread T1 here