Skip to content

Commit

Permalink
changes from review
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen committed Dec 5, 2024
1 parent 011e9ce commit 1f2f70d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 4 additions & 3 deletions compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,9 @@ INTERCEPTOR(int, accept4, int socket, struct sockaddr *address,
__rtsan_notify_intercepted_call("accept4");
return REAL(accept4)(socket, address, address_len, flags);
}
#define RTSAN_MAYBE_INTERCEPT_ACCEPT4 INTERCEPT_FUNCTION(accept4)
#else
#define RTSAN_MAYBE_INTERCEPT_ACCEPT4
#endif

// I/O Multiplexing
Expand Down Expand Up @@ -964,9 +967,7 @@ void __rtsan::InitializeInterceptors() {
INTERCEPT_FUNCTION(sendto);
INTERCEPT_FUNCTION(shutdown);
INTERCEPT_FUNCTION(socket);
#if SANITIZER_INTERCEPT_ACCEPT4
INTERCEPT_FUNCTION(accept4);
#endif
RTSAN_MAYBE_INTERCEPT_ACCEPT4;

RTSAN_MAYBE_INTERCEPT_SELECT;
INTERCEPT_FUNCTION(pselect);
Expand Down
10 changes: 10 additions & 0 deletions compiler-rt/lib/rtsan/tests/rtsan_test_interceptors_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,16 @@ TEST(TestRtsanInterceptors, AcceptingASocketDiesWhenRealtime) {
ExpectNonRealtimeSurvival(Func);
}

#if SANITIZER_INTERCEPT_ACCEPT4
TEST(TestRtsanInterceptors, Accepting4ASocketDiesWhenRealtime) {
auto Func = []() {
EXPECT_LT(accept4(kNotASocketFd, nullptr, nullptr, 0), 0);
};
ExpectRealtimeDeath(Func, "accept4");
ExpectNonRealtimeSurvival(Func);
}
#endif

TEST(TestRtsanInterceptors, ConnectingASocketDiesWhenRealtime) {
auto Func = []() { EXPECT_NE(connect(kNotASocketFd, nullptr, 0), 0); };
ExpectRealtimeDeath(Func, "connect");
Expand Down

0 comments on commit 1f2f70d

Please sign in to comment.