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
This commit is contained in:
Dmitry Vyukov 2022-11-29 16:51:48 +01:00
parent aaf73ae266
commit 099997540f
2 changed files with 12 additions and 1 deletions

View File

@ -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;

View File

@ -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);