Skip to content

Commit da7943b

Browse files
committed
[NFC][LSAN] Add more pthread interceptors
They are empty for now. Follow up patches will introduce behaviour changes.
1 parent b9d7ecc commit da7943b

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

compiler-rt/lib/lsan/lsan_interceptors.cpp

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -479,10 +479,38 @@ INTERCEPTOR(int, pthread_create, void *th, void *attr,
479479
return res;
480480
}
481481

482-
INTERCEPTOR(int, pthread_join, void *t, void **arg) {
483-
return REAL(pthread_join)(t, arg);
482+
INTERCEPTOR(int, pthread_join, void *thread, void **retval) {
483+
return REAL(pthread_join)(thread, retval);
484484
}
485485

486+
INTERCEPTOR(int, pthread_detach, void *thread) {
487+
return REAL(pthread_detach)(thread);
488+
}
489+
490+
INTERCEPTOR(int, pthread_exit, void *retval) {
491+
return REAL(pthread_exit)(retval);
492+
}
493+
494+
# if SANITIZER_INTERCEPT_TRYJOIN
495+
INTERCEPTOR(int, pthread_tryjoin_np, void *thread, void **ret) {
496+
return REAL(pthread_tryjoin_np)(thread, ret);
497+
}
498+
# define LSAN_MAYBE_INTERCEPT_TRYJOIN INTERCEPT_FUNCTION(pthread_tryjoin_np)
499+
# else
500+
# define LSAN_MAYBE_INTERCEPT_TRYJOIN
501+
# endif // SANITIZER_INTERCEPT_TRYJOIN
502+
503+
# if SANITIZER_INTERCEPT_TIMEDJOIN
504+
INTERCEPTOR(int, pthread_timedjoin_np, void *thread, void **ret,
505+
const struct timespec *abstime) {
506+
return REAL(pthread_timedjoin_np)(thread, ret, abstime);
507+
}
508+
# define LSAN_MAYBE_INTERCEPT_TIMEDJOIN \
509+
INTERCEPT_FUNCTION(pthread_timedjoin_np)
510+
# else
511+
# define LSAN_MAYBE_INTERCEPT_TIMEDJOIN
512+
# endif // SANITIZER_INTERCEPT_TIMEDJOIN
513+
486514
DEFINE_REAL_PTHREAD_FUNCTIONS
487515

488516
INTERCEPTOR(void, _exit, int status) {
@@ -518,6 +546,10 @@ void InitializeInterceptors() {
518546
LSAN_MAYBE_INTERCEPT_MALLOPT;
519547
INTERCEPT_FUNCTION(pthread_create);
520548
INTERCEPT_FUNCTION(pthread_join);
549+
INTERCEPT_FUNCTION(pthread_detach);
550+
INTERCEPT_FUNCTION(pthread_exit);
551+
LSAN_MAYBE_INTERCEPT_TIMEDJOIN;
552+
LSAN_MAYBE_INTERCEPT_TRYJOIN;
521553
INTERCEPT_FUNCTION(_exit);
522554

523555
LSAN_MAYBE_INTERCEPT__LWP_EXIT;

compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,8 @@
367367
(SI_LINUX_NOT_ANDROID || SI_SOLARIS)
368368
#define SANITIZER_INTERCEPT_PTHREAD_BARRIERATTR_GETPSHARED \
369369
(SI_LINUX_NOT_ANDROID && !SI_NETBSD)
370+
#define SANITIZER_INTERCEPT_TRYJOIN SI_GLIBC
371+
#define SANITIZER_INTERCEPT_TIMEDJOIN SI_GLIBC
370372
#define SANITIZER_INTERCEPT_THR_EXIT SI_FREEBSD
371373
#define SANITIZER_INTERCEPT_TMPNAM SI_POSIX
372374
#define SANITIZER_INTERCEPT_TMPNAM_R (SI_GLIBC || SI_SOLARIS)

0 commit comments

Comments
 (0)