From f4c43287f23273d93356e63652ae45fc92f6f677 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Sun, 7 May 2023 16:12:04 -0700 Subject: [PATCH] [NFC][HWASAN] Add more pthread interceptors They are empty for now. Follow up patches will introduce behaviour changes. --- .../lib/hwasan/hwasan_interceptors.cpp | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp index 299cf371e32a..d5866b8b94b0 100644 --- a/compiler-rt/lib/hwasan/hwasan_interceptors.cpp +++ b/compiler-rt/lib/hwasan/hwasan_interceptors.cpp @@ -77,6 +77,25 @@ INTERCEPTOR(int, pthread_join, void *t, void **arg) { return REAL(pthread_join)(t, arg); } +INTERCEPTOR(int, pthread_detach, void *thread) { + return REAL(pthread_detach)(thread); +} + +INTERCEPTOR(int, pthread_exit, void *retval) { + return REAL(pthread_exit)(retval); +} + +# if SANITIZER_GLIBC +INTERCEPTOR(int, pthread_tryjoin_np, void *thread, void **ret) { + return REAL(pthread_tryjoin_np)(thread, ret); +} + +INTERCEPTOR(int, pthread_timedjoin_np, void *thread, void **ret, + const struct timespec *abstime) { + return REAL(pthread_timedjoin_np)(thread, ret, abstime); +} +# endif + DEFINE_REAL_PTHREAD_FUNCTIONS DEFINE_REAL(int, vfork) @@ -271,6 +290,12 @@ void InitializeInterceptors() { # endif // __linux__ INTERCEPT_FUNCTION(pthread_create); INTERCEPT_FUNCTION(pthread_join); + INTERCEPT_FUNCTION(pthread_detach); + INTERCEPT_FUNCTION(pthread_exit); +# if SANITIZER_GLIBC + INTERCEPT_FUNCTION(pthread_tryjoin_np); + INTERCEPT_FUNCTION(pthread_timedjoin_np); +# endif # endif inited = 1; -- 2.34.1