Skip to content

Conversation

@kongy
Copy link
Collaborator

@kongy kongy commented Jan 22, 2025

MUSL have different signatures for sendmmsg and recvmmsg.

This fixes build breakage from #123484.

@llvmbot
Copy link
Member

llvmbot commented Jan 22, 2025

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: Yi Kong (kongy)

Changes

MUSL have different signatures for sendmmsg and recvmmsg.


Full diff: https://github.com/llvm/llvm-project/pull/123907.diff

1 Files Affected:

  • (modified) compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp (+9-1)
diff --git a/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp b/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
index 112191f52648e7..008cc676a6ae55 100644
--- a/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
+++ b/compiler-rt/lib/rtsan/rtsan_interceptors_posix.cpp
@@ -894,8 +894,13 @@ INTERCEPTOR(ssize_t, sendmsg, int socket, const struct msghdr *message,
 }
 
 #if SANITIZER_INTERCEPT_SENDMMSG
+#if SANITIZER_MUSL
+INTERCEPTOR(int, sendmmsg, int socket, struct mmsghdr *message,
+            unsigned int len, unsigned int flags) {
+#else
 INTERCEPTOR(int, sendmmsg, int socket, struct mmsghdr *message,
             unsigned int len, int flags) {
+#endif
   __rtsan_notify_intercepted_call("sendmmsg");
   return REAL(sendmmsg)(socket, message, len, flags);
 }
@@ -927,7 +932,10 @@ INTERCEPTOR(ssize_t, recvmsg, int socket, struct msghdr *message, int flags) {
 }
 
 #if SANITIZER_INTERCEPT_RECVMMSG
-#if defined(__GLIBC_MINOR__) && __GLIBC_MINOR__ < 21
+#if SANITIZER_MUSL
+INTERCEPTOR(int, recvmmsg, int socket, struct mmsghdr *message,
+            unsigned int len, unsigned int flags, struct timespec *timeout) {
+#elif defined(__GLIBC_MINOR__) && __GLIBC_MINOR__ < 21
 INTERCEPTOR(int, recvmmsg, int socket, struct mmsghdr *message,
             unsigned int len, int flags, const struct timespec *timeout) {
 #else

@devnexen
Copy link
Member

What a mess :) thanks for fixing it.

Copy link
Member

@devnexen devnexen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but waiting @cjappl

Copy link
Contributor

@cjappl cjappl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thank you!!

This is just musings doesn't affect this review - I wonder if there is a better way to organize all the differences of signatures across versions/libcs/OSs. One that is more readable or maintainable.

As we continue adding interceptors we may want to re-organize in some way

@kongy kongy merged commit 2ee36d4 into llvm:main Jan 22, 2025
8 of 9 checks passed
@appujee
Copy link
Contributor

appujee commented Jan 28, 2025

Fixes #123689

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants