[compiler-rt] r299884 - [msan] Choose in runtime if IPv4 or IPv6 are supported.
Hal Finkel via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 12 17:04:32 PDT 2017
On 04/12/2017 06:31 PM, Vitaly Buka wrote:
> Does this fail on just before? E.g. on r299883
> It's weird that it fails IpTests/MemorySanitizerIpTest.accept/*0*
> which suppose to be IPv4 as before.
Both the /0 test which fail, and the /1 tests which fail, say where
GetParam() = 10. The 10 is AF_INET6 (it would say 2 for AF_INET). So it
is just the IPv6 tests that are failing.
Heh; actually, I think the problem here is the code:
for (int i : std::vector<int>(AF_INET, AF_INET6)) {
int s = socket(i, SOCK_STREAM, 0);
if (s > 0) {
result.push_back(i);
close(s);
}
}
std::vector<int>(AF_INET, AF_INET6) creates a vector of size 2 (because
AF_INET == 2) where each element is initialized to AF_INET6. This is not
what you intended.
Also, it seems that the systems in my build cluster don't have valid
IPv6 loopback addresses. I did some quick tests and a bind on an IPv6
socket succeeds with in6addr_any but fails with in6addr_loopback. I
suppose this makes sense because the lo interface does not seem to have
an IPv6 address:
$ ifconfig lo
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.255.255.0
loop txqueuelen 1 (Local Loopback)
RX packets ...
I suspect this explains why the IPv6 tests, which want to bind to
in6addr_loopback, fail.
Thanks again,
Hal
>
> On Wed, Apr 12, 2017 at 4:22 PM Vitaly Buka <vitalybuka at google.com
> <mailto:vitalybuka at google.com>> wrote:
>
> Oh, my mistake squashing local git commits.
> This CL reverts nothing.
>
> On Wed, Apr 12, 2017 at 4:07 PM Hal Finkel <hfinkel at anl.gov
> <mailto:hfinkel at anl.gov>> wrote:
>
> FYI: This is failing on my build cluster. I see output like this:
>
> [ RUN ] IpTests/MemorySanitizerIpTest.accept/0
> /home/hfinkel/public/src/llvm/projects/compiler-rt/lib/msan/tests/msan_test.cc:972:
> Failure
> Expected: 0
> To be equal to: res
> Which is: -1
> [ FAILED ] IpTests/MemorySanitizerIpTest.accept/0, where
> GetParam() =
> 10 (3 ms)
>
> ...
>
> MemorySanitizer-Unit ::
> Msan-x86_64-Test/IpTests/MemorySanitizerIpTest.accept/0
> MemorySanitizer-Unit ::
> Msan-x86_64-Test/IpTests/MemorySanitizerIpTest.accept/1
> MemorySanitizer-Unit ::
> Msan-x86_64-Test/IpTests/MemorySanitizerIpTest.recvmsg/0
> MemorySanitizer-Unit ::
> Msan-x86_64-Test/IpTests/MemorySanitizerIpTest.recvmsg/1
> MemorySanitizer-Unit ::
> Msan-x86_64-with-call-Test/IpTests/MemorySanitizerIpTest.accept/0
> MemorySanitizer-Unit ::
> Msan-x86_64-with-call-Test/IpTests/MemorySanitizerIpTest.accept/1
> MemorySanitizer-Unit ::
> Msan-x86_64-with-call-Test/IpTests/MemorySanitizerIpTest.recvmsg/0
> MemorySanitizer-Unit ::
> Msan-x86_64-with-call-Test/IpTests/MemorySanitizerIpTest.recvmsg/1
>
> The call to bind() is failing (i.e. returning -1).
>
> On 04/10/2017 04:03 PM, Vitaly Buka via llvm-commits wrote:
> > Author: vitalybuka
> > Date: Mon Apr 10 16:03:18 2017
> > New Revision: 299884
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=299884&view=rev
> > Log:
> > [msan] Choose in runtime if IPv4 or IPv6 are supported.
> >
> > Summary: This reverts commit
> cab5051c691ce27a7ffac41e8e76ceb222ad9549.
>
> Which commit is this?
>
> -Hal
>
> >
> > Reviewers: eugenis
> >
> > Subscribers: mgorny, llvm-commits
> >
> > Differential Revision: https://reviews.llvm.org/D31894
> >
> > Modified:
> > compiler-rt/trunk/lib/msan/tests/CMakeLists.txt
> > compiler-rt/trunk/lib/msan/tests/msan_test.cc
> >
> > Modified: compiler-rt/trunk/lib/msan/tests/CMakeLists.txt
> > URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/tests/CMakeLists.txt?rev=299884&r1=299883&r2=299884&view=diff
> >
> ==============================================================================
> > --- compiler-rt/trunk/lib/msan/tests/CMakeLists.txt (original)
> > +++ compiler-rt/trunk/lib/msan/tests/CMakeLists.txt Mon Apr
> 10 16:03:18 2017
> > @@ -35,6 +35,7 @@ set(MSAN_UNITTEST_COMMON_CFLAGS
> > -Wno-zero-length-array
> > -Wno-uninitialized
> > -Werror=sign-compare
> > + -Wno-gnu-zero-variadic-macro-arguments
> > )
> > set(MSAN_UNITTEST_INSTRUMENTED_CFLAGS
> > ${MSAN_UNITTEST_COMMON_CFLAGS}
> >
> > Modified: compiler-rt/trunk/lib/msan/tests/msan_test.cc
> > URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/msan/tests/msan_test.cc?rev=299884&r1=299883&r2=299884&view=diff
> >
> ==============================================================================
> > --- compiler-rt/trunk/lib/msan/tests/msan_test.cc (original)
> > +++ compiler-rt/trunk/lib/msan/tests/msan_test.cc Mon Apr 10
> 16:03:18 2017
> > @@ -902,9 +902,7 @@ class SocketAddr4 : public SocketAddr {
> > sai_.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
> > }
> >
> > - sockaddr *ptr() override {
> > - return reinterpret_cast<sockaddr *>(&sai_);
> > - }
> > + sockaddr *ptr() override { return
> reinterpret_cast<sockaddr *>(&sai_); }
> >
> > size_t size() const override { return sizeof(sai_); }
> >
> > @@ -912,14 +910,60 @@ class SocketAddr4 : public SocketAddr {
> > sockaddr_in sai_;
> > };
> >
> > -template <class... Args>
> > -std::unique_ptr<SocketAddr> CreateSockAddr(Args... args) {
> > - return std::unique_ptr<SocketAddr>(new SocketAddr4(args...));
> > +class SocketAddr6 : public SocketAddr {
> > + public:
> > + SocketAddr6() { EXPECT_POISONED(sai_); }
> > + explicit SocketAddr6(uint16_t port) {
> > + memset(&sai_, 0, sizeof(sai_));
> > + sai_.sin6_family = AF_INET6;
> > + sai_.sin6_port = port;
> > + sai_.sin6_addr = in6addr_loopback;
> > + }
> > +
> > + sockaddr *ptr() override { return
> reinterpret_cast<sockaddr *>(&sai_); }
> > +
> > + size_t size() const override { return sizeof(sai_); }
> > +
> > + private:
> > + sockaddr_in6 sai_;
> > +};
> > +
> > +class MemorySanitizerIpTest : public
> ::testing::TestWithParam<int> {
> > + public:
> > + void SetUp() override {
> > + ASSERT_TRUE(GetParam() == AF_INET || GetParam() ==
> AF_INET6);
> > + }
> > +
> > + template <class... Args>
> > + std::unique_ptr<SocketAddr> CreateSockAddr(Args... args)
> const {
> > + if (GetParam() == AF_INET)
> > + return std::unique_ptr<SocketAddr>(new
> SocketAddr4(args...));
> > + return std::unique_ptr<SocketAddr>(new
> SocketAddr6(args...));
> > + }
> > +
> > + int CreateSocket(int socket_type) const {
> > + return socket(GetParam(), socket_type, 0);
> > + }
> > +};
> > +
> > +std::vector<int> GetAvailableIpSocketFamilies() {
> > + std::vector<int> result;
> > +
> > + for (int i : std::vector<int>(AF_INET, AF_INET6)) {
> > + int s = socket(i, SOCK_STREAM, 0);
> > + if (s > 0) {
> > + result.push_back(i);
> > + close(s);
> > + }
> > + }
> > +
> > + return result;
> > }
> >
> > -int CreateSocket(int socket_type) { return socket(AF_INET,
> socket_type, 0); }
> > +INSTANTIATE_TEST_CASE_P(IpTests, MemorySanitizerIpTest,
> > + ::testing::ValuesIn(GetAvailableIpSocketFamilies()));
> >
> > -TEST(MemorySanitizer, accept) {
> > +TEST_P(MemorySanitizerIpTest, accept) {
> > int listen_socket = CreateSocket(SOCK_STREAM);
> > ASSERT_LT(0, listen_socket);
> >
> > @@ -963,7 +1007,7 @@ TEST(MemorySanitizer, accept) {
> > close(listen_socket);
> > }
> >
> > -TEST(MemorySanitizer, recvmsg) {
> > +TEST_P(MemorySanitizerIpTest, recvmsg) {
> > int server_socket = CreateSocket(SOCK_DGRAM);
> > ASSERT_LT(0, server_socket);
> >
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
> --
> Hal Finkel
> Lead, Compiler Technology and Programming Languages
> Leadership Computing Facility
> Argonne National Laboratory
>
--
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170412/d830603d/attachment.html>
More information about the llvm-commits
mailing list