Skip to content

Commit 3fc723e

Browse files
authored
[compiler-rt][sanitizer] fix msghdr for musl (#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`.
1 parent 7cb256b commit 3fc723e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,30 @@ struct __sanitizer_cmsghdr {
478478
int cmsg_level;
479479
int cmsg_type;
480480
};
481+
# elif SANITIZER_MUSL
482+
struct __sanitizer_msghdr {
483+
void *msg_name;
484+
unsigned msg_namelen;
485+
struct __sanitizer_iovec *msg_iov;
486+
int msg_iovlen;
487+
# if SANITIZER_WORDSIZE == 64
488+
int __pad1;
489+
# endif
490+
void *msg_control;
491+
unsigned msg_controllen;
492+
# if SANITIZER_WORDSIZE == 64
493+
int __pad2;
494+
# endif
495+
int msg_flags;
496+
};
497+
struct __sanitizer_cmsghdr {
498+
unsigned cmsg_len;
499+
# if SANITIZER_WORDSIZE == 64
500+
int __pad1;
501+
# endif
502+
int cmsg_level;
503+
int cmsg_type;
504+
};
481505
# else
482506
// In POSIX, int msg_iovlen; socklen_t msg_controllen; socklen_t cmsg_len; but
483507
// many implementations don't conform to the standard.

0 commit comments

Comments
 (0)