Skip to content

Commit d947f9f

Browse files
committed
changes from review
1 parent 011e9ce commit d947f9f

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,9 @@ INTERCEPTOR(int, accept4, int socket, struct sockaddr *address,
713713
__rtsan_notify_intercepted_call("accept4");
714714
return REAL(accept4)(socket, address, address_len, flags);
715715
}
716+
#define RTSAN_MAYBE_INTERCEPT_ACCEPT4 INTERCEPT_FUNCTION(accept4)
717+
#else
718+
#define RTSAN_MAYBE_INTERCEPT_ACCEPT4
716719
#endif
717720

718721
// I/O Multiplexing
@@ -964,9 +967,7 @@ void __rtsan::InitializeInterceptors() {
964967
INTERCEPT_FUNCTION(sendto);
965968
INTERCEPT_FUNCTION(shutdown);
966969
INTERCEPT_FUNCTION(socket);
967-
#if SANITIZER_INTERCEPT_ACCEPT4
968-
INTERCEPT_FUNCTION(accept4);
969-
#endif
970+
RTSAN_MAYBE_INTERCEPT_ACCEPT4;
970971

971972
RTSAN_MAYBE_INTERCEPT_SELECT;
972973
INTERCEPT_FUNCTION(pselect);

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,14 @@ TEST(TestRtsanInterceptors, AcceptingASocketDiesWhenRealtime) {
860860
ExpectNonRealtimeSurvival(Func);
861861
}
862862

863+
#if SANITIZER_INTERCEPT_ACCEPT4
864+
TEST(TestRtsanInterceptors, Accepting4ASocketDiesWhenRealtime) {
865+
auto Func = []() { EXPECT_LT(accept4(kNotASocketFd, nullptr, nullptr, 0), 0); };
866+
ExpectRealtimeDeath(Func, "accept4");
867+
ExpectNonRealtimeSurvival(Func);
868+
}
869+
#endif
870+
863871
TEST(TestRtsanInterceptors, ConnectingASocketDiesWhenRealtime) {
864872
auto Func = []() { EXPECT_NE(connect(kNotASocketFd, nullptr, 0), 0); };
865873
ExpectRealtimeDeath(Func, "connect");

0 commit comments

Comments
 (0)