Skip to content

Commit

Permalink
[NFC][LSAN] Add more pthread interceptors
Browse files Browse the repository at this point in the history
They are empty for now. Follow up patches will introduce behaviour
changes.
  • Loading branch information
vitalybuka committed May 7, 2023
1 parent b9d7ecc commit da7943b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
36 changes: 34 additions & 2 deletions compiler-rt/lib/lsan/lsan_interceptors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,38 @@ INTERCEPTOR(int, pthread_create, void *th, void *attr,
return res;
}

INTERCEPTOR(int, pthread_join, void *t, void **arg) {
return REAL(pthread_join)(t, arg);
INTERCEPTOR(int, pthread_join, void *thread, void **retval) {
return REAL(pthread_join)(thread, retval);
}

INTERCEPTOR(int, pthread_detach, void *thread) {
return REAL(pthread_detach)(thread);
}

INTERCEPTOR(int, pthread_exit, void *retval) {
return REAL(pthread_exit)(retval);
}

# if SANITIZER_INTERCEPT_TRYJOIN
INTERCEPTOR(int, pthread_tryjoin_np, void *thread, void **ret) {
return REAL(pthread_tryjoin_np)(thread, ret);
}
# define LSAN_MAYBE_INTERCEPT_TRYJOIN INTERCEPT_FUNCTION(pthread_tryjoin_np)
# else
# define LSAN_MAYBE_INTERCEPT_TRYJOIN
# endif // SANITIZER_INTERCEPT_TRYJOIN

# if SANITIZER_INTERCEPT_TIMEDJOIN
INTERCEPTOR(int, pthread_timedjoin_np, void *thread, void **ret,
const struct timespec *abstime) {
return REAL(pthread_timedjoin_np)(thread, ret, abstime);
}
# define LSAN_MAYBE_INTERCEPT_TIMEDJOIN \
INTERCEPT_FUNCTION(pthread_timedjoin_np)
# else
# define LSAN_MAYBE_INTERCEPT_TIMEDJOIN
# endif // SANITIZER_INTERCEPT_TIMEDJOIN

DEFINE_REAL_PTHREAD_FUNCTIONS

INTERCEPTOR(void, _exit, int status) {
Expand Down Expand Up @@ -518,6 +546,10 @@ void InitializeInterceptors() {
LSAN_MAYBE_INTERCEPT_MALLOPT;
INTERCEPT_FUNCTION(pthread_create);
INTERCEPT_FUNCTION(pthread_join);
INTERCEPT_FUNCTION(pthread_detach);
INTERCEPT_FUNCTION(pthread_exit);
LSAN_MAYBE_INTERCEPT_TIMEDJOIN;
LSAN_MAYBE_INTERCEPT_TRYJOIN;
INTERCEPT_FUNCTION(_exit);

LSAN_MAYBE_INTERCEPT__LWP_EXIT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@
(SI_LINUX_NOT_ANDROID || SI_SOLARIS)
#define SANITIZER_INTERCEPT_PTHREAD_BARRIERATTR_GETPSHARED \
(SI_LINUX_NOT_ANDROID && !SI_NETBSD)
#define SANITIZER_INTERCEPT_TRYJOIN SI_GLIBC
#define SANITIZER_INTERCEPT_TIMEDJOIN SI_GLIBC
#define SANITIZER_INTERCEPT_THR_EXIT SI_FREEBSD
#define SANITIZER_INTERCEPT_TMPNAM SI_POSIX
#define SANITIZER_INTERCEPT_TMPNAM_R (SI_GLIBC || SI_SOLARIS)
Expand Down

0 comments on commit da7943b

Please sign in to comment.