[compiler-rt] 5ec6294 - [msan] Add pthread_*join_np interceptors

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Mon May 8 14:08:44 PDT 2023


Author: Vitaly Buka
Date: 2023-05-08T14:08:28-07:00
New Revision: 5ec62943ac188994d7c7d54ea995398a4c62e74f

URL: https://github.com/llvm/llvm-project/commit/5ec62943ac188994d7c7d54ea995398a4c62e74f
DIFF: https://github.com/llvm/llvm-project/commit/5ec62943ac188994d7c7d54ea995398a4c62e74f.diff

LOG: [msan] Add pthread_*join_np interceptors

Added: 
    

Modified: 
    compiler-rt/lib/msan/msan_interceptors.cpp
    compiler-rt/test/sanitizer_common/TestCases/Linux/pthread_join.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/msan/msan_interceptors.cpp b/compiler-rt/lib/msan/msan_interceptors.cpp
index 4dbcd064d41e..8cf724b3949f 100644
--- a/compiler-rt/lib/msan/msan_interceptors.cpp
+++ b/compiler-rt/lib/msan/msan_interceptors.cpp
@@ -1120,6 +1120,24 @@ INTERCEPTOR(int, pthread_join, void *thread, void **retval) {
   return res;
 }
 
+#if SANITIZER_GLIBC
+INTERCEPTOR(int, pthread_tryjoin_np, void *thread, void **retval) {
+  ENSURE_MSAN_INITED();
+  int res = REAL(pthread_tryjoin_np)(thread, retval);
+  if (!res && retval)
+    __msan_unpoison(retval, sizeof(*retval));
+  return res;
+}
+
+INTERCEPTOR(int, pthread_timedjoin_np, void *thread, void **retval,
+            const struct timespec *abstime) {
+  int res = REAL(pthread_timedjoin_np)(thread, retval, abstime);
+  if (!res && retval)
+    __msan_unpoison(retval, sizeof(*retval));
+  return res;
+}
+#endif
+
 DEFINE_REAL_PTHREAD_FUNCTIONS
 
 extern char *tzname[2];
@@ -1777,6 +1795,10 @@ void InitializeInterceptors() {
 #endif
   INTERCEPT_FUNCTION(pthread_join);
   INTERCEPT_FUNCTION(pthread_key_create);
+#if SANITIZER_GLIBC
+  INTERCEPT_FUNCTION(pthread_tryjoin_np);
+  INTERCEPT_FUNCTION(pthread_timedjoin_np);
+#endif
 
 #if SANITIZER_NETBSD
   INTERCEPT_FUNCTION(__libc_thr_keycreate);

diff  --git a/compiler-rt/test/sanitizer_common/TestCases/Linux/pthread_join.cpp b/compiler-rt/test/sanitizer_common/TestCases/Linux/pthread_join.cpp
index 2b35b163b143..212a28dd3985 100644
--- a/compiler-rt/test/sanitizer_common/TestCases/Linux/pthread_join.cpp
+++ b/compiler-rt/test/sanitizer_common/TestCases/Linux/pthread_join.cpp
@@ -4,8 +4,6 @@
 // FIXME: Crashes on some bots in pthread_exit.
 // RUN: %run %t %if tsan %{ 0 %} %else %{ 1 %}
 
-// XFAIL: msan
-
 // REQUIRES: glibc
 
 #include <assert.h>


        


More information about the llvm-commits mailing list