[compiler-rt] b9d7ecc - [NFC][ASAN] Add more pthread interceptors
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Sun May 7 16:25:19 PDT 2023
Author: Vitaly Buka
Date: 2023-05-07T16:21:56-07:00
New Revision: b9d7ecc2ed5c2266573cf8d48f5cb6cf68fa7a08
URL: https://github.com/llvm/llvm-project/commit/b9d7ecc2ed5c2266573cf8d48f5cb6cf68fa7a08
DIFF: https://github.com/llvm/llvm-project/commit/b9d7ecc2ed5c2266573cf8d48f5cb6cf68fa7a08.diff
LOG: [NFC][ASAN] Add more pthread interceptors
They are empty for now. Follow up patches will introduce behaviour
changes.
Added:
Modified:
compiler-rt/lib/asan/asan_interceptors.cpp
compiler-rt/lib/asan/asan_interceptors.h
Removed:
################################################################################
diff --git a/compiler-rt/lib/asan/asan_interceptors.cpp b/compiler-rt/lib/asan/asan_interceptors.cpp
index 9c5a7e4c32884..774f06779726d 100644
--- a/compiler-rt/lib/asan/asan_interceptors.cpp
+++ b/compiler-rt/lib/asan/asan_interceptors.cpp
@@ -234,10 +234,31 @@ INTERCEPTOR(int, pthread_create, void *thread,
return result;
}
-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 ASAN_INTERCEPT_TRYJOIN
+INTERCEPTOR(int, pthread_tryjoin_np, void *thread, void **ret) {
+ return REAL(pthread_tryjoin_np)(thread, ret);
+}
+# endif
+
+# if ASAN_INTERCEPT_TIMEDJOIN
+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
#endif // ASAN_INTERCEPT_PTHREAD_CREATE
@@ -723,6 +744,16 @@ void InitializeAsanInterceptors() {
ASAN_INTERCEPT_FUNC(pthread_create);
#endif
ASAN_INTERCEPT_FUNC(pthread_join);
+ ASAN_INTERCEPT_FUNC(pthread_detach);
+ ASAN_INTERCEPT_FUNC(pthread_exit);
+# endif
+
+# if ASAN_INTERCEPT_TIMEDJOIN
+ ASAN_INTERCEPT_FUNC(pthread_timedjoin_np);
+#endif
+
+#if ASAN_INTERCEPT_TRYJOIN
+ ASAN_INTERCEPT_FUNC(pthread_tryjoin_np);
#endif
// Intercept atexit function.
diff --git a/compiler-rt/lib/asan/asan_interceptors.h b/compiler-rt/lib/asan/asan_interceptors.h
index e7bec02f048d9..93e8b8e1d545e 100644
--- a/compiler-rt/lib/asan/asan_interceptors.h
+++ b/compiler-rt/lib/asan/asan_interceptors.h
@@ -112,6 +112,14 @@ void InitializePlatformInterceptors();
# define ASAN_INTERCEPT___STRDUP 0
#endif
+#if SANITIZER_GLIBC && ASAN_INTERCEPT_PTHREAD_CREATE
+# define ASAN_INTERCEPT_TIMEDJOIN 1
+# define ASAN_INTERCEPT_TRYJOIN 1
+#else
+# define ASAN_INTERCEPT_TIMEDJOIN 0
+# define ASAN_INTERCEPT_TRYJOIN 0
+#endif
+
#if SANITIZER_LINUX && \
(defined(__arm__) || defined(__aarch64__) || defined(__i386__) || \
defined(__x86_64__) || SANITIZER_RISCV64 || SANITIZER_LOONGARCH64)
More information about the llvm-commits
mailing list