[compiler-rt] 0999975 - tsan: fix epoll_pwait2 interceptor
Dmitry Vyukov via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 30 01:37:17 PST 2022
Author: Dmitry Vyukov
Date: 2022-11-30T10:37:11+01:00
New Revision: 099997540f45a50f1bfb1da85cd222e3509b87cb
URL: https://github.com/llvm/llvm-project/commit/099997540f45a50f1bfb1da85cd222e3509b87cb
DIFF: https://github.com/llvm/llvm-project/commit/099997540f45a50f1bfb1da85cd222e3509b87cb.diff
LOG: tsan: fix epoll_pwait2 interceptor
epoll_pwait2 is new and may not be present in libc and/or kernel.
Since we effectively add it to libc (as will be probed by the program
using dlsym or a weak function pointer) we need to handle the case
when it's not present in the actual libc.
Reviewed By: melver
Differential Revision: https://reviews.llvm.org/D138929
Added:
Modified:
compiler-rt/lib/sanitizer_common/sanitizer_errno_codes.h
compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
Removed:
################################################################################
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_errno_codes.h b/compiler-rt/lib/sanitizer_common/sanitizer_errno_codes.h
index 192e9392d494a..3917b2817f2e9 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_errno_codes.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_errno_codes.h
@@ -25,6 +25,7 @@ namespace __sanitizer {
#define errno_EBUSY 16
#define errno_EINVAL 22
#define errno_ENAMETOOLONG 36
+#define errno_ENOSYS 38
// Those might not present or their value
diff er on
diff erent platforms.
extern const int errno_EOWNERDEAD;
diff --git a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
index 72a771d762da6..bab725c2b07ac 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
@@ -1945,7 +1945,17 @@ TSAN_INTERCEPTOR(int, epoll_pwait, int epfd, void *ev, int cnt, int timeout,
TSAN_INTERCEPTOR(int, epoll_pwait2, int epfd, void *ev, int cnt, void *timeout,
void *sigmask) {
- SCOPED_TSAN_INTERCEPTOR(epoll_pwait2, epfd, ev, cnt, timeout, sigmask);
+ SCOPED_INTERCEPTOR_RAW(epoll_pwait2, epfd, ev, cnt, timeout, sigmask);
+ // This function is new and may not be present in libc and/or kernel.
+ // Since we effectively add it to libc (as will be probed by the program
+ // using dlsym or a weak function pointer) we need to handle the case
+ // when it's not present in the actual libc.
+ if (!REAL(epoll_pwait2)) {
+ errno = errno_ENOSYS;
+ return -1;
+ }
+ if (MustIgnoreInterceptor(thr))
+ REAL(epoll_pwait2)(epfd, ev, cnt, timeout, sigmask);
if (epfd >= 0)
FdAccess(thr, pc, epfd);
int res = BLOCK_REAL(epoll_pwait2)(epfd, ev, cnt, timeout, sigmask);
More information about the llvm-commits
mailing list