Skip to content

[rtsan] NFC: Add comment about O_NONBLOCK behavior #116189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ struct DlsymAlloc : public DlSymAllocator<DlsymAlloc> {
// Filesystem

INTERCEPTOR(int, open, const char *path, int oflag, ...) {
// TODO Establish whether we should intercept here if the flag contains
// O_NONBLOCK
// We do not early exit if O_NONBLOCK is set.
// O_NONBLOCK **does not prevent the syscall** it simply sets the FD to be in
// nonblocking mode, which is a different concept than our
// [[clang::nonblocking]], and is not rt-safe. This behavior was confirmed
// using Instruments on Darwin with a simple test program
__rtsan_notify_intercepted_call("open");

if (OpenReadsVaArgs(oflag)) {
Expand All @@ -77,8 +80,7 @@ INTERCEPTOR(int, open, const char *path, int oflag, ...) {

#if SANITIZER_INTERCEPT_OPEN64
INTERCEPTOR(int, open64, const char *path, int oflag, ...) {
// TODO Establish whether we should intercept here if the flag contains
// O_NONBLOCK
// See comment above about O_NONBLOCK
__rtsan_notify_intercepted_call("open64");

if (OpenReadsVaArgs(oflag)) {
Expand All @@ -97,8 +99,7 @@ INTERCEPTOR(int, open64, const char *path, int oflag, ...) {
#endif // SANITIZER_INTERCEPT_OPEN64

INTERCEPTOR(int, openat, int fd, const char *path, int oflag, ...) {
// TODO Establish whether we should intercept here if the flag contains
// O_NONBLOCK
// See comment above about O_NONBLOCK
__rtsan_notify_intercepted_call("openat");

if (OpenReadsVaArgs(oflag)) {
Expand All @@ -114,8 +115,7 @@ INTERCEPTOR(int, openat, int fd, const char *path, int oflag, ...) {

#if SANITIZER_INTERCEPT_OPENAT64
INTERCEPTOR(int, openat64, int fd, const char *path, int oflag, ...) {
// TODO Establish whether we should intercept here if the flag contains
// O_NONBLOCK
// See comment above about O_NONBLOCK
__rtsan_notify_intercepted_call("openat64");

if (OpenReadsVaArgs(oflag)) {
Expand All @@ -134,17 +134,15 @@ INTERCEPTOR(int, openat64, int fd, const char *path, int oflag, ...) {
#endif // SANITIZER_INTERCEPT_OPENAT64

INTERCEPTOR(int, creat, const char *path, mode_t mode) {
// TODO Establish whether we should intercept here if the flag contains
// O_NONBLOCK
// See comment above about O_NONBLOCK
__rtsan_notify_intercepted_call("creat");
const int result = REAL(creat)(path, mode);
return result;
}

#if SANITIZER_INTERCEPT_CREAT64
INTERCEPTOR(int, creat64, const char *path, mode_t mode) {
// TODO Establish whether we should intercept here if the flag contains
// O_NONBLOCK
// See comment above about O_NONBLOCK
__rtsan_notify_intercepted_call("creat64");
const int result = REAL(creat64)(path, mode);
return result;
Expand Down
Loading