Skip to content

[rtsan] NFC: Fix style of some interceptors not using MAYBE #118145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 28 additions & 14 deletions compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,17 +368,32 @@ INTERCEPTOR(void, OSSpinLockLock, volatile OSSpinLock *lock) {
return REAL(OSSpinLockLock)(lock);
}
#pragma clang diagnostic pop
#define RTSAN_MAYBE_INTERCEPT_OSSPINLOCKLOCK INTERCEPT_FUNCTION(OSSpinLockLock)
#else
#define RTSAN_MAYBE_INTERCEPT_OSSPINLOCKLOCK
#endif // SANITIZER_APPLE

#if SANITIZER_APPLE
INTERCEPTOR(void, os_unfair_lock_lock, os_unfair_lock_t lock) {
__rtsan_notify_intercepted_call("os_unfair_lock_lock");
return REAL(os_unfair_lock_lock)(lock);
}
#elif SANITIZER_LINUX
#define RTSAN_MAYBE_INTERCEPT_OS_UNFAIR_LOCK_LOCK \
INTERCEPT_FUNCTION(os_unfair_lock_lock)
#else
#define RTSAN_MAYBE_INTERCEPT_OS_UNFAIR_LOCK_LOCK
#endif // SANITIZER_APPLE

#if SANITIZER_LINUX
INTERCEPTOR(int, pthread_spin_lock, pthread_spinlock_t *spinlock) {
__rtsan_notify_intercepted_call("pthread_spin_lock");
return REAL(pthread_spin_lock)(spinlock);
}
#endif
#define RTSAN_MAYBE_INTERCEPT_PTHREAD_SPIN_LOCK \
INTERCEPT_FUNCTION(pthread_spin_lock)
#else
#define RTSAN_MAYBE_INTERCEPT_PTHREAD_SPIN_LOCK
#endif // SANITIZER_LINUX

INTERCEPTOR(int, pthread_create, pthread_t *thread, const pthread_attr_t *attr,
void *(*start_routine)(void *), void *arg) {
Expand Down Expand Up @@ -539,13 +554,19 @@ INTERCEPTOR(void *, memalign, size_t alignment, size_t size) {
__rtsan_notify_intercepted_call("memalign");
return REAL(memalign)(alignment, size);
}
#define RTSAN_MAYBE_INTERCEPT_MEMALIGN INTERCEPT_FUNCTION(memalign)
#else
#define RTSAN_MAYBE_INTERCEPT_MEMALIGN
#endif

#if SANITIZER_INTERCEPT_PVALLOC
INTERCEPTOR(void *, pvalloc, size_t size) {
__rtsan_notify_intercepted_call("pvalloc");
return REAL(pvalloc)(size);
}
#define RTSAN_MAYBE_INTERCEPT_PVALLOC INTERCEPT_FUNCTION(pvalloc)
#else
#define RTSAN_MAYBE_INTERCEPT_PVALLOC
#endif

INTERCEPTOR(void *, mmap, void *addr, size_t length, int prot, int flags,
Expand Down Expand Up @@ -783,12 +804,8 @@ void __rtsan::InitializeInterceptors() {
INTERCEPT_FUNCTION(munmap);
INTERCEPT_FUNCTION(shm_open);
INTERCEPT_FUNCTION(shm_unlink);
#if SANITIZER_INTERCEPT_MEMALIGN
INTERCEPT_FUNCTION(memalign);
#endif
#if SANITIZER_INTERCEPT_PVALLOC
INTERCEPT_FUNCTION(pvalloc);
#endif
RTSAN_MAYBE_INTERCEPT_MEMALIGN;
RTSAN_MAYBE_INTERCEPT_PVALLOC;

INTERCEPT_FUNCTION(open);
RTSAN_MAYBE_INTERCEPT_OPEN64;
Expand Down Expand Up @@ -820,12 +837,9 @@ void __rtsan::InitializeInterceptors() {
INTERCEPT_FUNCTION(dup2);
INTERCEPT_FUNCTION(ioctl);

#if SANITIZER_APPLE
INTERCEPT_FUNCTION(OSSpinLockLock);
INTERCEPT_FUNCTION(os_unfair_lock_lock);
#elif SANITIZER_LINUX
INTERCEPT_FUNCTION(pthread_spin_lock);
#endif
RTSAN_MAYBE_INTERCEPT_OSSPINLOCKLOCK;
RTSAN_MAYBE_INTERCEPT_OS_UNFAIR_LOCK_LOCK;
RTSAN_MAYBE_INTERCEPT_PTHREAD_SPIN_LOCK;

INTERCEPT_FUNCTION(pthread_create);
INTERCEPT_FUNCTION(pthread_mutex_lock);
Expand Down