[compiler-rt] [rtsan] NFC: Add comment about O_NONBLOCK behavior (PR #116189)
Chris Apple via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 14 01:36:55 PST 2024
https://github.com/cjappl created https://github.com/llvm/llvm-project/pull/116189
None
>From c7783d62c51a864c53ef14c33e8a9b34c76d2fea Mon Sep 17 00:00:00 2001
From: Chris Apple <cja-private at pm.me>
Date: Thu, 14 Nov 2024 09:36:13 +0000
Subject: [PATCH] [rtsan] NFC: Add comment about O_NONBLOCK behavior
---
.../lib/rtsan/rtsan_interceptors_posix.cpp | 22 +++++++++----------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp b/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
index c3fcd4f2da85ce..3a1b1f6524745f 100644
--- a/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
+++ b/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
@@ -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)) {
@@ -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)) {
@@ -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)) {
@@ -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)) {
@@ -134,8 +134,7 @@ 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;
@@ -143,8 +142,7 @@ INTERCEPTOR(int, creat, const char *path, mode_t mode) {
#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;
More information about the llvm-commits
mailing list