[compiler-rt] 16eb853 - [tsan] Add pthread_cond_clockwait interceptor

Ying Yi via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 18 08:22:23 PST 2020


Hi Vitaly,


It seems that this commit has caused a test failure.

      FAIL: ThreadSanitizer-powerpc64le::clockwait_double_lock.c


You can see here: http://lab.llvm.org:8011/#/builders/105/builds/1951.


Could you please fix it?

Thanks,


Ying

On Wed, Nov 18, 2020 at 11:02 AM Vitaly Buka via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

>
> Author: Vitaly Buka
> Date: 2020-11-18T03:01:58-08:00
> New Revision: 16eb853ffdd1a1ad7c95455b7795c5f004402e46
>
> URL:
> https://github.com/llvm/llvm-project/commit/16eb853ffdd1a1ad7c95455b7795c5f004402e46
> DIFF:
> https://github.com/llvm/llvm-project/commit/16eb853ffdd1a1ad7c95455b7795c5f004402e46.diff
>
> LOG: [tsan] Add pthread_cond_clockwait interceptor
>
> Fixes https://github.com/google/sanitizers/issues/1259
>
> Reviewed By: dvyukov
>
> Differential Revision: https://reviews.llvm.org/D91684
>
> Added:
>     compiler-rt/test/tsan/Linux/clockwait_double_lock.c
>
> Modified:
>     compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
>
> Removed:
>
>
>
>
> ################################################################################
> diff  --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
> b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
> index 74e6ae6ea74a..7a731df34d80 100644
> --- a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
> +++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
> @@ -1202,6 +1202,21 @@ INTERCEPTOR(int, pthread_cond_timedwait, void *c,
> void *m, void *abstime) {
>        m);
>  }
>
> +#if SANITIZER_LINUX
> +INTERCEPTOR(int, pthread_cond_clockwait, void *c, void *m,
> +            __sanitizer_clockid_t clock, void *abstime) {
> +  void *cond = init_cond(c);
> +  SCOPED_TSAN_INTERCEPTOR(pthread_cond_clockwait, cond, m, clock,
> abstime);
> +  return cond_wait(
> +      thr, pc, &si,
> +      [=]() { return REAL(pthread_cond_clockwait)(cond, m, clock,
> abstime); },
> +      cond, m);
> +}
> +#define TSAN_MAYBE_PTHREAD_COND_CLOCKWAIT
> TSAN_INTERCEPT(pthread_cond_clockwait)
> +#else
> +#define TSAN_MAYBE_PTHREAD_COND_CLOCKWAIT
> +#endif
> +
>  #if SANITIZER_MAC
>  INTERCEPTOR(int, pthread_cond_timedwait_relative_np, void *c, void *m,
>              void *reltime) {
> @@ -2716,6 +2731,8 @@ void InitializeInterceptors() {
>    TSAN_INTERCEPT_VER(pthread_cond_timedwait, PTHREAD_ABI_BASE);
>    TSAN_INTERCEPT_VER(pthread_cond_destroy, PTHREAD_ABI_BASE);
>
> +  TSAN_MAYBE_PTHREAD_COND_CLOCKWAIT;
> +
>    TSAN_INTERCEPT(pthread_mutex_init);
>    TSAN_INTERCEPT(pthread_mutex_destroy);
>    TSAN_INTERCEPT(pthread_mutex_trylock);
>
> diff  --git a/compiler-rt/test/tsan/Linux/clockwait_double_lock.c
> b/compiler-rt/test/tsan/Linux/clockwait_double_lock.c
> new file mode 100644
> index 000000000000..8378fc3c7c82
> --- /dev/null
> +++ b/compiler-rt/test/tsan/Linux/clockwait_double_lock.c
> @@ -0,0 +1,31 @@
> +// Regression test for https://github.com/google/sanitizers/issues/1259
> +// RUN: %clang_tsan -O1 %s -o %t && %run %t
> +
> +#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;
> +}
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>


-- 
Ying Yi
SN Systems - Sony Interactive Entertainment
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201118/32ed1324/attachment.html>


More information about the llvm-commits mailing list