-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tsan] Add pthread_cond_clockwait interceptor
Disable the test on old systems. pthread_cond_clockwait is supported by glibc-2.30. It also supported by Android api 30 even though we do not run tsan on Android. Fixes google/sanitizers#1259 Reviewed By: dvyukov
- Loading branch information
1 parent
d5dfcb5
commit 195b0fe
Showing
3 changed files
with
56 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Regression test for https://github.com/google/sanitizers/issues/1259 | ||
// RUN: %clang_tsan -O1 %s -o %t && %run %t | ||
// REQUIRES: glibc-2.30 || android-30 | ||
|
||
#define _GNU_SOURCE | ||
#include <pthread.h> | ||
|
||
pthread_cond_t cv; | ||
pthread_mutex_t mtx; | ||
|
||
void *fn(void *vp) { | ||
pthread_mutex_lock(&mtx); | ||
pthread_cond_signal(&cv); | ||
pthread_mutex_unlock(&mtx); | ||
return NULL; | ||
} | ||
|
||
int main() { | ||
pthread_mutex_lock(&mtx); | ||
|
||
pthread_t tid; | ||
pthread_create(&tid, NULL, fn, NULL); | ||
|
||
struct timespec ts; | ||
clock_gettime(CLOCK_MONOTONIC, &ts); | ||
ts.tv_sec += 10; | ||
pthread_cond_clockwait(&cv, &mtx, CLOCK_MONOTONIC, &ts); | ||
pthread_mutex_unlock(&mtx); | ||
|
||
pthread_join(tid, NULL); | ||
return 0; | ||
} |