This is an archive of the discontinued LLVM Phabricator instance.

[sanitizer] Fix build for new GLIBC msghdr/cmsghdr definition
ClosedPublic

Authored by zatrazz on Jun 6 2016, 12:19 PM.

Details

Summary

GLIBC now follows POSIX [1] for both msghdr and cmsghdr definitions,
which means that msg_iovlen, msg_controllen, and cmsg_len are no
longer size_t but sockelen_t for 64-bits architectures. The final struct
size does not change, since paddings were added.

This patch fixes the build issue against GLIBC 2.24 socket.h header by
using the same definition for internal sanitizer_msghdr and
sanitizer_cmsghdr.

[1] http://pubs.opengroup.org/onlinepubs/9699919799/

Diff Detail

Event Timeline

zatrazz updated this revision to Diff 59760.Jun 6 2016, 12:19 PM
zatrazz retitled this revision from to [sanitizer] Fix build for new GLIBC msghdr/cmsghdr definition.
zatrazz updated this object.
zatrazz added reviewers: samsonov, eugenis, pcc, dvyukov.
zatrazz set the repository for this revision to rL LLVM.
zatrazz added a project: Restricted Project.
zatrazz added subscribers: rengolin, llvm-commits.
eugenis added inline comments.Jun 6 2016, 1:18 PM
lib/sanitizer_common/sanitizer_platform_limits_posix.cc
1023 ↗(On Diff #59760)

You are disabling the test on older glibc. Why? It used to work just fine.

lib/sanitizer_common/sanitizer_platform_limits_posix.h
465

This is too confusing. Please provide the entire msghdr & cmsghdr definitions for the three cases (be, le, pre-2.24) w/o conditional macros inside.

zatrazz added inline comments.Jun 6 2016, 1:43 PM
lib/sanitizer_common/sanitizer_platform_limits_posix.cc
1023 ↗(On Diff #59760)

That's not its intention, __GLIBC_PREREQ will only set to 0 if is not yet defined (mainly when it is built using interposed features.h that do not define it).

lib/sanitizer_common/sanitizer_platform_limits_posix.h
465

Right, I will change it.

eugenis added inline comments.Jun 6 2016, 1:47 PM
lib/sanitizer_common/sanitizer_platform_limits_posix.cc
1023 ↗(On Diff #59760)

Could you elaborate? What is this "interposed features.h" configuration, and why does it fail this test? This indicates that the struct definition does not match the system, which means certain interceptors are broken. Can it be fixed?

zatrazz added inline comments.Jun 6 2016, 2:02 PM
lib/sanitizer_common/sanitizer_platform_limits_posix.cc
1023 ↗(On Diff #59760)

And now I realize my mistake here, I will fix it.

zatrazz added inline comments.Jun 6 2016, 2:14 PM
lib/sanitizer_common/sanitizer_platform_limits_posix.cc
1023 ↗(On Diff #59760)

Sorry if I was not clear enough, this part is trying to 'fix' a build for gcc libsanitizer build (where it does not define __GLIBC_PREREQ due the interposed features.h header). Now I realize this piece is should be in llvm compiler-rt and I will remove it.

zatrazz updated this revision to Diff 59785.Jun 6 2016, 2:20 PM
zatrazz removed rL LLVM as the repository for this revision.

Update patch based on previous comments.

eugenis accepted this revision.Jun 6 2016, 2:22 PM
eugenis edited edge metadata.

LGTM

lib/sanitizer_common/sanitizer_platform_limits_posix.h
475

&& defined(_LP64

This revision is now accepted and ready to land.Jun 6 2016, 2:22 PM
zatrazz added inline comments.Jun 6 2016, 2:40 PM
lib/sanitizer_common/sanitizer_platform_limits_posix.h
475

Right, I will fix it on commit.

zatrazz closed this revision.Jun 7 2016, 6:39 AM