This is an archive of the discontinued LLVM Phabricator instance.

tsan: fix epoll_pwait2 interceptor
ClosedPublic

Authored by dvyukov on Nov 29 2022, 7:57 AM.

Details

Summary

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.

Diff Detail

Event Timeline

dvyukov created this revision.Nov 29 2022, 7:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 29 2022, 7:57 AM
Herald added a subscriber: Enna1. · View Herald Transcript
dvyukov requested review of this revision.Nov 29 2022, 7:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 29 2022, 7:57 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript
melver added inline comments.Nov 29 2022, 9:18 AM
compiler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp
1954

sanitizer_posix.cpp already includes things like errno.h - can we include errno.h and use ENOSYS?

Also is this return value correct?

On success, epoll_wait() returns the number of file descriptors
ready for the requested I/O, or zero if no file descriptor became
ready during the requested timeout milliseconds.  On failure,
epoll_wait() returns -1 and errno is set to indicate the error.

https://man7.org/linux/man-pages/man2/epoll_wait.2.html

dvyukov updated this revision to Diff 478838.Nov 30 2022, 12:43 AM

fixed return value

dvyukov added a comment.EditedNov 30 2022, 12:47 AM

Also is this return value correct?

Good point!

Somehow the internal test I was using to check this passed...

sanitizer_posix.cpp already includes things like errno.h - can we include errno.h and use ENOSYS?

We avoided including any system headers to avoid conflicts in definitions and redefinitions. I would do it differently (with asm aliases), but that's how we do it now.
I see there is already sanitizer_common/sanitizer_errno_codes.h, so I extended it.

PTAL

melver accepted this revision.Nov 30 2022, 12:55 AM
This revision is now accepted and ready to land.Nov 30 2022, 12:55 AM
This revision was landed with ongoing or failed builds.Nov 30 2022, 1:37 AM
This revision was automatically updated to reflect the committed changes.