Skip to content

Conversation

deaklajos
Copy link
Contributor

Backports: 3fc723e (#136195)

Ran into the issue on Alpine when building with TSAN that __sanitizer_msghdr and the msghdr provided by musl did not match. This caused lots of tsan reports and an eventual termination of the application by the oom during a sendmsg.

@llvmbot
Copy link
Member

llvmbot commented Sep 18, 2025

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

Author: Deák Lajos (deaklajos)

Changes

Backports: 3fc723e (#136195)

Ran into the issue on Alpine when building with TSAN that __sanitizer_msghdr and the msghdr provided by musl did not match. This caused lots of tsan reports and an eventual termination of the application by the oom during a sendmsg.


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

1 Files Affected:

  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h (+24)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
index f118d53f0df80..24966523f3a02 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -478,6 +478,30 @@ struct __sanitizer_cmsghdr {
   int cmsg_level;
   int cmsg_type;
 };
+#  elif SANITIZER_MUSL
+struct __sanitizer_msghdr {
+  void *msg_name;
+  unsigned msg_namelen;
+  struct __sanitizer_iovec *msg_iov;
+  int msg_iovlen;
+#    if SANITIZER_WORDSIZE == 64
+  int __pad1;
+#    endif
+  void *msg_control;
+  unsigned msg_controllen;
+#    if SANITIZER_WORDSIZE == 64
+  int __pad2;
+#    endif
+  int msg_flags;
+};
+struct __sanitizer_cmsghdr {
+  unsigned cmsg_len;
+#    if SANITIZER_WORDSIZE == 64
+  int __pad1;
+#    endif
+  int cmsg_level;
+  int cmsg_type;
+};
 #  else
 // In POSIX, int msg_iovlen; socklen_t msg_controllen; socklen_t cmsg_len; but
 // many implementations don't conform to the standard.

Copy link

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
Please turn off Keep my email addresses private setting in your account.
See LLVM Developer Policy and LLVM Discourse for more information.

@deaklajos
Copy link
Contributor Author

@vitalybuka

@nikic nikic added this to the LLVM 21.x Release milestone Sep 25, 2025
@github-project-automation github-project-automation bot moved this to Needs Triage in LLVM Release Status Sep 25, 2025
@nikic nikic moved this from Needs Triage to Needs Review in LLVM Release Status Sep 25, 2025
@github-project-automation github-project-automation bot moved this from Needs Review to Needs Merge in LLVM Release Status Sep 30, 2025
Ran into the issue on Alpine when building with TSAN that
`__sanitizer_msghdr` and the `msghdr` provided by musl did not match.
This caused lots of tsan reports and an eventual termination of the
application by the oom during a `sendmsg`.
@dyung dyung force-pushed the compiler-rt/backport-musl-msghdr branch from 859ebb3 to 7da3233 Compare October 1, 2025 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs Merge
Development

Successfully merging this pull request may close these issues.

4 participants