diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_errno_codes.h b/compiler-rt/lib/sanitizer_common/sanitizer_errno_codes.h index 192e9392d494..3917b2817f2e 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 differ on different 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 72a771d762da..bab725c2b07a 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);