]>
Commit | Line | Data |
---|---|---|
1a4d82fc JJ |
1 | // RUN: %clangxx_tsan -O1 %s -o %t && %run %t 2>&1 | FileCheck %s |
2 | #include <stdio.h> | |
3 | ||
92a42be0 | 4 | // Defined by tsan. |
1a4d82fc JJ |
5 | extern "C" void *__interceptor_malloc(unsigned long size); |
6 | extern "C" void __interceptor_free(void *p); | |
7 | ||
8 | extern "C" void *malloc(unsigned long size) { | |
9 | static int first = 0; | |
10 | if (__sync_lock_test_and_set(&first, 1) == 0) | |
5bcae85e | 11 | fprintf(stderr, "user malloc\n"); |
1a4d82fc JJ |
12 | return __interceptor_malloc(size); |
13 | } | |
14 | ||
15 | extern "C" void free(void *p) { | |
16 | __interceptor_free(p); | |
17 | } | |
18 | ||
19 | int main() { | |
20 | volatile char *p = (char*)malloc(10); | |
21 | p[0] = 0; | |
22 | free((void*)p); | |
23 | } | |
24 | ||
25 | // CHECK: user malloc | |
26 | // CHECK-NOT: ThreadSanitizer | |
27 |