Skip to content

Commit

Permalink
[msan] Add pthread_*join_np interceptors
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalybuka committed May 8, 2023
1 parent 39c1005 commit 5ec6294
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
22 changes: 22 additions & 0 deletions compiler-rt/lib/msan/msan_interceptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit 5ec6294

Please sign in to comment.