@@ -60,8 +60,11 @@ struct DlsymAlloc : public DlSymAllocator<DlsymAlloc> {
6060// Filesystem
6161
6262INTERCEPTOR (int , open, const char *path, int oflag, ...) {
63- // TODO Establish whether we should intercept here if the flag contains
64- // O_NONBLOCK
63+ // We do not early exit if O_NONBLOCK is set.
64+ // O_NONBLOCK **does not prevent the syscall** it simply sets the FD to be in
65+ // nonblocking mode, which is a different concept than our
66+ // [[clang::nonblocking]], and is not rt-safe. This behavior was confirmed
67+ // using Instruments on Darwin with a simple test program
6568 __rtsan_notify_intercepted_call (" open" );
6669
6770 if (OpenReadsVaArgs (oflag)) {
@@ -77,8 +80,7 @@ INTERCEPTOR(int, open, const char *path, int oflag, ...) {
7780
7881#if SANITIZER_INTERCEPT_OPEN64
7982INTERCEPTOR (int , open64, const char *path, int oflag, ...) {
80- // TODO Establish whether we should intercept here if the flag contains
81- // O_NONBLOCK
83+ // See comment above about O_NONBLOCK
8284 __rtsan_notify_intercepted_call (" open64" );
8385
8486 if (OpenReadsVaArgs (oflag)) {
@@ -97,8 +99,7 @@ INTERCEPTOR(int, open64, const char *path, int oflag, ...) {
9799#endif // SANITIZER_INTERCEPT_OPEN64
98100
99101INTERCEPTOR (int , openat, int fd, const char *path, int oflag, ...) {
100- // TODO Establish whether we should intercept here if the flag contains
101- // O_NONBLOCK
102+ // See comment above about O_NONBLOCK
102103 __rtsan_notify_intercepted_call (" openat" );
103104
104105 if (OpenReadsVaArgs (oflag)) {
@@ -114,8 +115,7 @@ INTERCEPTOR(int, openat, int fd, const char *path, int oflag, ...) {
114115
115116#if SANITIZER_INTERCEPT_OPENAT64
116117INTERCEPTOR (int , openat64, int fd, const char *path, int oflag, ...) {
117- // TODO Establish whether we should intercept here if the flag contains
118- // O_NONBLOCK
118+ // See comment above about O_NONBLOCK
119119 __rtsan_notify_intercepted_call (" openat64" );
120120
121121 if (OpenReadsVaArgs (oflag)) {
@@ -134,17 +134,15 @@ INTERCEPTOR(int, openat64, int fd, const char *path, int oflag, ...) {
134134#endif // SANITIZER_INTERCEPT_OPENAT64
135135
136136INTERCEPTOR (int , creat, const char *path, mode_t mode) {
137- // TODO Establish whether we should intercept here if the flag contains
138- // O_NONBLOCK
137+ // See comment above about O_NONBLOCK
139138 __rtsan_notify_intercepted_call (" creat" );
140139 const int result = REAL (creat)(path, mode);
141140 return result;
142141}
143142
144143#if SANITIZER_INTERCEPT_CREAT64
145144INTERCEPTOR (int , creat64, const char *path, mode_t mode) {
146- // TODO Establish whether we should intercept here if the flag contains
147- // O_NONBLOCK
145+ // See comment above about O_NONBLOCK
148146 __rtsan_notify_intercepted_call (" creat64" );
149147 const int result = REAL (creat64)(path, mode);
150148 return result;
0 commit comments