Skip to content

Commit 7c55426

Browse files
authored
Revert "[rtsan] Intercept aligned_alloc on all versions of OSX if available on build machine (#112780)" (#113982)
This reverts commit 97fb21a. Due to issue brought up in #112780 > Unfortunately this breaks the build on our (automerger) bots, which have -mmacosx-version-min=10.13 and also -Werror=unguarded-availability-new . I was thinking about patching it via wrapping in __builtin_available check (which I believe is the right one to use, as it should match the -mmacosx-version-min ) - but can't actually think of a quick fix, due to interceptors being defined via C macros. > llvm-project/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp:475:21: error: 'aligned_alloc' is only available on macOS 10.15 or newer [-Werror,-Wunguarded-availability-new] 475 | INTERCEPTOR(void *, aligned_alloc, SIZE_T alignment, SIZE_T size) {
1 parent 8e6856e commit 7c55426

File tree

2 files changed

+6
-33
lines changed

2 files changed

+6
-33
lines changed

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

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,13 @@ TEST(TestRtsanInterceptors, VallocDiesWhenRealtime) {
122122
ExpectNonRealtimeSurvival(Func);
123123
}
124124

125-
#if __has_builtin(__builtin_available) && SANITIZER_APPLE
126-
#define ALIGNED_ALLOC_AVAILABLE() (__builtin_available(macOS 10.15, *))
127-
#else
128-
// We are going to assume this is true until we hit systems where it isn't
129-
#define ALIGNED_ALLOC_AVAILABLE() (true)
130-
#endif
131-
125+
#if SANITIZER_INTERCEPT_ALIGNED_ALLOC
132126
TEST(TestRtsanInterceptors, AlignedAllocDiesWhenRealtime) {
133-
if (ALIGNED_ALLOC_AVAILABLE()) {
134-
auto Func = []() { EXPECT_NE(nullptr, aligned_alloc(16, 32)); };
135-
ExpectRealtimeDeath(Func, "aligned_alloc");
136-
ExpectNonRealtimeSurvival(Func);
137-
}
127+
auto Func = []() { EXPECT_NE(nullptr, aligned_alloc(16, 32)); };
128+
ExpectRealtimeDeath(Func, "aligned_alloc");
129+
ExpectNonRealtimeSurvival(Func);
138130
}
131+
#endif
139132

140133
// free_sized and free_aligned_sized (both C23) are not yet supported
141134
TEST(TestRtsanInterceptors, FreeDiesWhenRealtime) {

compiler-rt/lib/sanitizer_common/sanitizer_platform_interceptors.h

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -84,25 +84,6 @@
8484
#define SI_NOT_MAC 1
8585
#endif
8686

87-
#if SANITIZER_APPLE
88-
# include <Availability.h>
89-
90-
// aligned_alloc was introduced in OSX 10.15
91-
// Linking will fail when using an older SDK
92-
# if defined(__MAC_10_15)
93-
// macOS 10.15 is greater than our minimal deployment target. To ensure we
94-
// generate a weak reference so the dylib continues to work on older
95-
// systems, we need to forward declare the intercepted function as "weak
96-
// imports".
97-
SANITIZER_WEAK_IMPORT void *aligned_alloc(__sanitizer::usize __alignment,
98-
__sanitizer::usize __size);
99-
# define SI_MAC_SDK_10_15_AVAILABLE 1
100-
# else
101-
# define SI_MAC_SDK_10_15_AVAILABLE 0
102-
# endif // defined(__MAC_10_15)
103-
104-
#endif // SANITIZER_APPLE
105-
10687
#if SANITIZER_IOS
10788
#define SI_IOS 1
10889
#else
@@ -519,8 +500,7 @@ SANITIZER_WEAK_IMPORT void *aligned_alloc(__sanitizer::usize __alignment,
519500
#define SANITIZER_INTERCEPT_PVALLOC (SI_GLIBC || SI_ANDROID)
520501
#define SANITIZER_INTERCEPT_CFREE (SI_GLIBC && !SANITIZER_RISCV64)
521502
#define SANITIZER_INTERCEPT_REALLOCARRAY SI_POSIX
522-
#define SANITIZER_INTERCEPT_ALIGNED_ALLOC \
523-
(!SI_MAC || SI_MAC_SDK_10_15_AVAILABLE)
503+
#define SANITIZER_INTERCEPT_ALIGNED_ALLOC (!SI_MAC)
524504
#define SANITIZER_INTERCEPT_MALLOC_USABLE_SIZE (!SI_MAC && !SI_NETBSD)
525505
#define SANITIZER_INTERCEPT_MCHECK_MPROBE SI_LINUX_NOT_ANDROID
526506
#define SANITIZER_INTERCEPT_WCSLEN 1

0 commit comments

Comments
 (0)