[ 
https://issues.apache.org/jira/browse/MESOS-6616?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16367532#comment-16367532
 ] 

Alexander Rukletsov commented on MESOS-6616:
--------------------------------------------

Back ported onto `1.4.x`:
{noformat}
commit dade7f5c68b54ebe18a50c619af1bb2ad49d4bd1
Author:     Alexander Rukletsov <al...@apache.org>
AuthorDate: Fri Feb 16 17:02:16 2018 +0100
Commit:     Alexander Rukletsov <al...@apache.org>
CommitDate: Fri Feb 16 17:13:45 2018 +0100

    Fixed the type-punned pointer and strict aliasing issue.
    
    Dereferencing a pointer cast from a different type of pointer
    violates the so-called "strict aliasing" rule, which is undefined
    behaviour and might lead to bugs when compiler optimizations are
    enabled.
    
    For more information on this topic, see
    https://blog.regehr.org/archives/959
    http://alas.matf.bg.ac.rs/manuals/lspe/snode=153.html
    
    Review: https://reviews.apache.org/r/64686/
{noformat}

> Error: dereferencing type-punned pointer will break strict-aliasing rules.
> --------------------------------------------------------------------------
>
>                 Key: MESOS-6616
>                 URL: https://issues.apache.org/jira/browse/MESOS-6616
>             Project: Mesos
>          Issue Type: Bug
>    Affects Versions: 1.1.0, 1.2.3, 1.3.1, 1.4.1
>         Environment: Fedora Rawhide;
> Debian 8.10 + gcc 5.5.0-6 with {{O2}}
>            Reporter: Orion Poplawski
>            Assignee: Alexander Rukletsov
>            Priority: Major
>              Labels: compile-error, mesosphere
>             Fix For: 1.4.2, 1.5.0
>
>
> Trying to update the mesos package to 1.1.0 in Fedora.  Getting:
> {noformat}
> libtool: compile:  g++ -DPACKAGE_NAME=\"mesos\" -DPACKAGE_TARNAME=\"mesos\" 
> -DPACKAGE_VERSION=\"1.1.0\" "-DPACKAGE_STRING=\"mesos 1.1.0\"" 
> -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"mesos\" 
> -DVERSION=\"1.1.0\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 
> -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 
> -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 
> -DLT_OBJDIR=\".libs/\" -DHAVE_CXX11=1 -DHAVE_PTHREAD_PRIO_INHERIT=1 
> -DHAVE_PTHREAD=1 -DHAVE_LIBZ=1 -DHAVE_FTS_H=1 -DHAVE_APR_POOLS_H=1 
> -DHAVE_LIBAPR_1=1 -DHAVE_BOOST_VERSION_HPP=1 -DHAVE_LIBCURL=1 
> -DHAVE_ELFIO_ELFIO_HPP=1 -DHAVE_GLOG_LOGGING_H=1 -DHAVE_HTTP_PARSER_H=1 
> -DMESOS_HAS_JAVA=1 -DHAVE_LEVELDB_DB_H=1 -DHAVE_LIBNL_3=1 
> -DHAVE_LIBNL_ROUTE_3=1 -DHAVE_LIBNL_IDIAG_3=1 -DWITH_NETWORK_ISOLATOR=1 
> -DHAVE_GOOGLE_PROTOBUF_MESSAGE_H=1 -DHAVE_EV_H=1 -DHAVE_PICOJSON_H=1 
> -DHAVE_LIBSASL2=1 -DHAVE_SVN_VERSION_H=1 -DHAVE_LIBSVN_SUBR_1=1 
> -DHAVE_SVN_DELTA_H=1 -DHAVE_LIBSVN_DELTA_1=1 -DHAVE_LIBZ=1 
> -DHAVE_ZOOKEEPER_H=1 -DHAVE_PYTHON=\"2.7\" -DMESOS_HAS_PYTHON=1 -I. -Wall 
> -Werror -Wsign-compare -DLIBDIR=\"/usr/lib64\" 
> -DPKGLIBEXECDIR=\"/usr/libexec/mesos\" -DPKGDATADIR=\"/usr/share/mesos\" 
> -DPKGMODULEDIR=\"/usr/lib64/mesos/modules\" -I../include -I../include 
> -I../include/mesos -DPICOJSON_USE_INT64 -D__STDC_FORMAT_MACROS 
> -I../3rdparty/libprocess/include -I../3rdparty/nvml-352.79 
> -I../3rdparty/stout/include -DHAS_AUTHENTICATION=1 -Iyes/include 
> -I/usr/include/subversion-1 -Iyes/include -Iyes/include -Iyes/include/libnl3 
> -Iyes/include -I/ -Iyes/include -I/usr/include/apr-1 -I/usr/include/apr-1.0 
> -I/builddir/build/BUILD/mesos-1.1.0/libev-4.15/include -isystem yes/include 
> -Iyes/include -I/usr/src/gmock -I/usr/src/gmock/include -I/usr/src/gmock/src 
> -I/usr/src/gmock/gtest -I/usr/src/gmock/gtest/include 
> -I/usr/src/gmock/gtest/src -Iyes/include -Iyes/include -I/usr/include 
> -I/builddir/build/BUILD/mesos-1.1.0/libev4.15/include -Iyes/include 
> -I/usr/include -I/usr/include/zookeeper -pthread -O2 -g -pipe -Wall 
> -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions 
> -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches 
> -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic 
> -DEV_CHILD_ENABLE=0 -I/builddir/build/BUILD/mesos-1.1.0/libev-4.15 
> -Wno-unused-local-typedefs -Wno-maybe-uninitialized -std=c++11 -c 
> health-check/health_checker.cpp  -fPIC -DPIC -o 
> health-check/.libs/libmesos_no_3rdparty_la-health_checker.o
> In file included from health-check/health_checker.cpp:51:0:
> ./linux/ns.hpp: In function 'Try<int> ns::clone(pid_t, int, const 
> std::function<int()>&, int)':
> ./linux/ns.hpp:480:69: error: dereferencing type-punned pointer will break 
> strict-aliasing rules [-Werror=strict-aliasing]
>      pid_t pid = ((struct ucred*) CMSG_DATA(CMSG_FIRSTHDR(&message)))->pid;
>                                                                      ^~
> ./linux/ns.hpp: In lambda function:
> ./linux/ns.hpp:581:59: error: dereferencing type-punned pointer will break 
> strict-aliasing rules [-Werror=strict-aliasing]
>        ((struct ucred*) CMSG_DATA(CMSG_FIRSTHDR(&message)))->pid = ::getpid();
>                                                            ^~
> ./linux/ns.hpp:582:59: error: dereferencing type-punned pointer will break 
> strict-aliasing rules [-Werror=strict-aliasing]
>        ((struct ucred*) CMSG_DATA(CMSG_FIRSTHDR(&message)))->uid = ::getuid();
>                                                            ^~
> ./linux/ns.hpp:583:59: error: dereferencing type-punned pointer will break 
> strict-aliasing rules [-Werror=strict-aliasing]
>        ((struct ucred*) CMSG_DATA(CMSG_FIRSTHDR(&message)))->gid = ::getgid();
>                                                            ^~
> cc1plus: all warnings being treated as errors
> make[2]: *** [Makefile:6655: 
> health-check/libmesos_no_3rdparty_la-health_checker.lo] Error 1
> {noformat}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to