@@ -60,8 +60,11 @@ struct DlsymAlloc : public DlSymAllocator<DlsymAlloc> {
60
60
// Filesystem
61
61
62
62
INTERCEPTOR (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
65
68
__rtsan_notify_intercepted_call (" open" );
66
69
67
70
if (OpenReadsVaArgs (oflag)) {
@@ -77,8 +80,7 @@ INTERCEPTOR(int, open, const char *path, int oflag, ...) {
77
80
78
81
#if SANITIZER_INTERCEPT_OPEN64
79
82
INTERCEPTOR (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
82
84
__rtsan_notify_intercepted_call (" open64" );
83
85
84
86
if (OpenReadsVaArgs (oflag)) {
@@ -97,8 +99,7 @@ INTERCEPTOR(int, open64, const char *path, int oflag, ...) {
97
99
#endif // SANITIZER_INTERCEPT_OPEN64
98
100
99
101
INTERCEPTOR (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
102
103
__rtsan_notify_intercepted_call (" openat" );
103
104
104
105
if (OpenReadsVaArgs (oflag)) {
@@ -114,8 +115,7 @@ INTERCEPTOR(int, openat, int fd, const char *path, int oflag, ...) {
114
115
115
116
#if SANITIZER_INTERCEPT_OPENAT64
116
117
INTERCEPTOR (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
119
119
__rtsan_notify_intercepted_call (" openat64" );
120
120
121
121
if (OpenReadsVaArgs (oflag)) {
@@ -134,17 +134,15 @@ INTERCEPTOR(int, openat64, int fd, const char *path, int oflag, ...) {
134
134
#endif // SANITIZER_INTERCEPT_OPENAT64
135
135
136
136
INTERCEPTOR (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
139
138
__rtsan_notify_intercepted_call (" creat" );
140
139
const int result = REAL (creat)(path, mode);
141
140
return result;
142
141
}
143
142
144
143
#if SANITIZER_INTERCEPT_CREAT64
145
144
INTERCEPTOR (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
148
146
__rtsan_notify_intercepted_call (" creat64" );
149
147
const int result = REAL (creat64)(path, mode);
150
148
return result;
0 commit comments