Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 1 | // RUN: %clangxx_tsan -O1 %s -o %t && %deflake %run %t | FileCheck %s |
Pirama Arumuga Nainar | 799172d | 2016-03-03 15:50:30 -0800 | [diff] [blame^] | 2 | // This test fails on powerpc64 on both VMA (44 and 46). |
| 3 | // The Tsan report is returning wrong information about |
| 4 | // the location of the race. |
| 5 | // XFAIL: powerpc64 |
Pirama Arumuga Nainar | cdce50b | 2015-07-01 12:26:56 -0700 | [diff] [blame] | 6 | #include "java.h" |
| 7 | |
| 8 | void foobar() { |
| 9 | } |
| 10 | |
| 11 | void barbaz() { |
| 12 | } |
| 13 | |
| 14 | void *Thread(void *p) { |
| 15 | barrier_wait(&barrier); |
| 16 | __tsan_read1_pc((jptr)p, (jptr)foobar + 1); |
| 17 | return 0; |
| 18 | } |
| 19 | |
| 20 | int main() { |
| 21 | barrier_init(&barrier, 2); |
| 22 | int const kHeapSize = 1024 * 1024; |
| 23 | jptr jheap = (jptr)malloc(kHeapSize + 8) + 8; |
| 24 | __tsan_java_init(jheap, kHeapSize); |
| 25 | const int kBlockSize = 16; |
| 26 | __tsan_java_alloc(jheap, kBlockSize); |
| 27 | pthread_t th; |
| 28 | pthread_create(&th, 0, Thread, (void*)jheap); |
| 29 | __tsan_write1_pc((jptr)jheap, (jptr)barbaz + 1); |
| 30 | barrier_wait(&barrier); |
| 31 | pthread_join(th, 0); |
| 32 | __tsan_java_free(jheap, kBlockSize); |
| 33 | fprintf(stderr, "DONE\n"); |
| 34 | return __tsan_java_fini(); |
| 35 | } |
| 36 | |
| 37 | // CHECK: WARNING: ThreadSanitizer: data race |
| 38 | // CHECK: #0 foobar |
| 39 | // CHECK: #0 barbaz |
| 40 | // CHECK: DONE |