Skip to content

Commit 12b2143

Browse files
committed
changes from review
1 parent 585c230 commit 12b2143

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,11 @@ INTERCEPTOR(int, madvise, void *addr, size_t length, int flag) {
813813
return REAL(madvise)(addr, length, flag);
814814
}
815815

816+
INTERCEPTOR(int, posix_madvise, void *addr, size_t length, int flag) {
817+
__rtsan_notify_intercepted_call("posix_madvise");
818+
return REAL(posix_madvise)(addr, length, flag);
819+
}
820+
816821
INTERCEPTOR(int, mprotect, void *addr, size_t length, int prot) {
817822
__rtsan_notify_intercepted_call("mprotect");
818823
return REAL(mprotect)(addr, length, prot);
@@ -1173,6 +1178,7 @@ void __rtsan::InitializeInterceptors() {
11731178
RTSAN_MAYBE_INTERCEPT_MMAP64;
11741179
INTERCEPT_FUNCTION(munmap);
11751180
INTERCEPT_FUNCTION(madvise);
1181+
INTERCEPT_FUNCTION(posix_madvise);
11761182
INTERCEPT_FUNCTION(mprotect);
11771183
INTERCEPT_FUNCTION(msync);
11781184
INTERCEPT_FUNCTION(mincore);

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

+9-3
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,12 @@ TEST_F(RtsanOpenedMmapTest, MadviseDiesWhenRealtime) {
244244
ExpectNonRealtimeSurvival(Func);
245245
}
246246

247+
TEST_F(RtsanOpenedMmapTest, PosixMadviseDiesWhenRealtime) {
248+
auto Func = [this]() { posix_madvise(GetAddr(), GetSize(), MADV_NORMAL); };
249+
ExpectRealtimeDeath(Func, "posix_madvise");
250+
ExpectNonRealtimeSurvival(Func);
251+
}
252+
247253
TEST_F(RtsanOpenedMmapTest, MprotectDiesWhenRealtime) {
248254
auto Func = [this]() { mprotect(GetAddr(), GetSize(), PROT_READ); };
249255
ExpectRealtimeDeath(Func, "mprotect");
@@ -258,11 +264,11 @@ TEST_F(RtsanOpenedMmapTest, MsyncDiesWhenRealtime) {
258264

259265
TEST_F(RtsanOpenedMmapTest, MincoreDiesWhenRealtime) {
260266
#if SANITIZER_APPLE
261-
char vec[GetSize() / 1024];
267+
std::vector<char> vec(GetSize() / 1024);
262268
#else
263-
unsigned char vec[GetSize() / 1024];
269+
std::vector<unsigned char> vec(GetSize() / 1024);
264270
#endif
265-
auto Func = [this, &vec]() { mincore(GetAddr(), GetSize(), vec); };
271+
auto Func = [this, &vec]() { mincore(GetAddr(), GetSize(), vec.data()); };
266272
ExpectRealtimeDeath(Func, "mincore");
267273
ExpectNonRealtimeSurvival(Func);
268274
}

0 commit comments

Comments
 (0)