| 1 | // Regression test for https://github.com/google/sanitizers/issues/1259 |
|---|---|
| 2 | // RUN: %clang_tsan -O1 %s -o %t && %run %t |
| 3 | // REQUIRES: glibc-2.30 || android-30 |
| 4 | |
| 5 | #define _GNU_SOURCE |
| 6 | #include <pthread.h> |
| 7 | |
| 8 | pthread_cond_t cv; |
| 9 | pthread_mutex_t mtx; |
| 10 | |
| 11 | void *fn(void *vp) { |
| 12 | pthread_mutex_lock(mutex: &mtx); |
| 13 | pthread_cond_signal(cond: &cv); |
| 14 | pthread_mutex_unlock(mutex: &mtx); |
| 15 | return NULL; |
| 16 | } |
| 17 | |
| 18 | int main() { |
| 19 | pthread_mutex_lock(mutex: &mtx); |
| 20 | |
| 21 | pthread_t tid; |
| 22 | pthread_create(newthread: &tid, NULL, start_routine: fn, NULL); |
| 23 | |
| 24 | struct timespec ts; |
| 25 | clock_gettime(CLOCK_MONOTONIC, tp: &ts); |
| 26 | ts.tv_sec += 10; |
| 27 | pthread_cond_clockwait(cond: &cv, mutex: &mtx, CLOCK_MONOTONIC, abstime: &ts); |
| 28 | pthread_mutex_unlock(mutex: &mtx); |
| 29 | |
| 30 | pthread_join(th: tid, NULL); |
| 31 | return 0; |
| 32 | } |
| 33 |
