Skip to content

Commit 42fedd1

Browse files
committed
do not bother with obsolete 64 interface with darwin
1 parent 4031334 commit 42fedd1

File tree

2 files changed

+45
-7
lines changed

2 files changed

+45
-7
lines changed

compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ INTERCEPTOR(int, fstat, int fd, struct stat *s) {
300300
return REAL(fstat)(fd, s);
301301
}
302302

303+
#if !SANITIZER_APPLE // deprecated for darwin
303304
INTERCEPTOR(int, stat64, const char *pathname, struct stat64 *s) {
304305
__rtsan_notify_intercepted_call("stat64");
305306
return REAL(stat64)(pathname, s);
@@ -314,6 +315,14 @@ INTERCEPTOR(int, fstat64, int fd, struct stat64 *s) {
314315
__rtsan_notify_intercepted_call("fstat64");
315316
return REAL(fstat64)(fd, s);
316317
}
318+
#define RTSAN_MAYBE_INTERCEPT_STAT64 INTERCEPTOR_FUNCTION(stat64)
319+
#define RTSAN_MAYBE_INTERCEPT_LSTAT64 INTERCEPTOR_FUNCTION(lstat64)
320+
#define RTSAN_MAYBE_INTERCEPT_FSTAT64 INTERCEPTOR_FUNCTION(fstat64)
321+
#else
322+
#define RTSAN_MAYBE_INTERCEPT_STAT64
323+
#define RTSAN_MAYBE_INTERCEPT_LSTAT64
324+
#define RTSAN_MAYBE_INTERCEPT_FSTAT64
325+
#endif
317326

318327
// Streams
319328

@@ -1470,9 +1479,9 @@ void __rtsan::InitializeInterceptors() {
14701479
INTERCEPT_FUNCTION(stat);
14711480
INTERCEPT_FUNCTION(lstat);
14721481
INTERCEPT_FUNCTION(fstat);
1473-
INTERCEPT_FUNCTION(stat64);
1474-
INTERCEPT_FUNCTION(lstat64);
1475-
INTERCEPT_FUNCTION(fstat64);
1482+
RTSAN_MAYBE_INTERCEPT_STAT64;
1483+
RTSAN_MAYBE_INTERCEPT_LSTAT64;
1484+
RTSAN_MAYBE_INTERCEPT_FSTAT64;
14761485
INTERCEPT_FUNCTION(fopen);
14771486
RTSAN_MAYBE_INTERCEPT_FOPEN64;
14781487
RTSAN_MAYBE_INTERCEPT_FREOPEN64;

compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -880,16 +880,16 @@ TEST_F(RtsanOpenedFileTest, StatDiesWhenRealtime) {
880880
struct stat s{};
881881
stat(GetTemporaryFilePath(), &s);
882882
};
883-
ExpectRealtimeDeath(Func, MAYBE_APPEND_64("stat"));
883+
ExpectRealtimeDeath(Func, "stat");
884884
ExpectNonRealtimeSurvival(Func);
885885
}
886886

887-
TEST_F(RtsanOpenedFileTest, LtatDiesWhenRealtime) {
887+
TEST_F(RtsanOpenedFileTest, LstatDiesWhenRealtime) {
888888
auto Func = [&]() {
889889
struct stat s{};
890890
lstat(GetTemporaryFilePath(), &s);
891891
};
892-
ExpectRealtimeDeath(Func, MAYBE_APPEND_64("lstat"));
892+
ExpectRealtimeDeath(Func, "lstat");
893893
ExpectNonRealtimeSurvival(Func);
894894
}
895895

@@ -898,10 +898,39 @@ TEST_F(RtsanOpenedFileTest, FstatDiesWhenRealtime) {
898898
struct stat s{};
899899
fstat(GetOpenFd(), &s);
900900
};
901-
ExpectRealtimeDeath(Func, MAYBE_APPEND_64("fstat"));
901+
ExpectRealtimeDeath(Func, "fstat");
902902
ExpectNonRealtimeSurvival(Func);
903903
}
904904

905+
#if !SANITIZER_APPLE // deprecated for darwin
906+
TEST_F(RtsanOpenedFileTest, Stat64DiesWhenRealtime) {
907+
auto Func = [&]() {
908+
struct stat64 s{};
909+
stat64(GetTemporaryFilePath(), &s);
910+
};
911+
ExpectRealtimeDeath(Func, "stat");
912+
ExpectNonRealtimeSurvival(Func);
913+
}
914+
915+
TEST_F(RtsanOpenedFileTest, Lstat64DiesWhenRealtime) {
916+
auto Func = [&]() {
917+
struct stat64 s{};
918+
lstat64(GetTemporaryFilePath(), &s);
919+
};
920+
ExpectRealtimeDeath(Func, "lstat64");
921+
ExpectNonRealtimeSurvival(Func);
922+
}
923+
924+
TEST_F(RtsanOpenedFileTest, Fstat64DiesWhenRealtime) {
925+
auto Func = [&]() {
926+
struct stat64 s{};
927+
fstat64(GetOpenFd(), &s);
928+
};
929+
ExpectRealtimeDeath(Func, "fstat64");
930+
ExpectNonRealtimeSurvival(Func);
931+
}
932+
#endif
933+
905934
TEST_F(RtsanFileTest, FcloseDiesWhenRealtime) {
906935
FILE *f = fopen(GetTemporaryFilePath(), "w");
907936
EXPECT_THAT(f, Ne(nullptr));

0 commit comments

Comments
 (0)