diff --git a/.travis.yml b/.travis.yml index c78ef0df..6fc85e96 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,9 +12,10 @@ script: - export OS="${TRAVIS_OS_NAME}" - ': ${NO_ASAN:=0}' - ': ${NO_VALGRIND:=0}' - - 'if (( !$NO_ASAN )); then extras/scripts/postsubmit.sh DebugAsan; fi' - - 'if (( !$NO_VALGRIND )); then extras/scripts/postsubmit.sh DebugValgrind; fi' + - 'if (( !$NO_ASAN && !$NO_UBSAN )); then extras/scripts/postsubmit.sh DebugAsanUbsan; fi' + - 'if (( !$NO_ASAN && $NO_UBSAN )); then extras/scripts/postsubmit.sh DebugAsan; fi' - 'if (( $NO_ASAN && $NO_VALGRIND )); then extras/scripts/postsubmit.sh DebugPlain; fi' + - 'if (( !$NO_VALGRIND )); then extras/scripts/postsubmit.sh DebugValgrind; fi' - 'if (( $NO_VALGRIND )); then extras/scripts/postsubmit.sh ReleasePlain; fi' - 'if (( !$NO_VALGRIND )); then extras/scripts/postsubmit.sh ReleaseValgrind; fi' @@ -43,10 +44,10 @@ matrix: # GCC - os: linux compiler: gcc - # Asan is disabled because it would fail with an error like: + # UBSan is disabled because it would fail with an error like: # runtime error: member call on null pointer of type 'const struct __lambda26' # This issue is fixed in the version of GCC shipped in Ubuntu 16.04. - env: UBUNTU=15.10 COMPILER=gcc-5 NO_ASAN=1 + env: UBUNTU=15.10 COMPILER=gcc-5 NO_UBSAN=1 # Clang with libstdc++ - os: linux compiler: clang @@ -60,20 +61,20 @@ matrix: env: UBUNTU=15.10 COMPILER=clang-3.6 STL=libc++ - os: linux compiler: clang - # Asan is disabled because it would fail with an error like: + # UBSan is disabled because it would fail with an error like: # /usr/include/c++/v1/memory:1554:35: runtime error: null pointer passed as argument 2, which is declared to never be null - env: UBUNTU=15.10 COMPILER=clang-3.8 STL=libc++ NO_ASAN=1 + env: UBUNTU=15.10 COMPILER=clang-3.8 STL=libc++ NO_UBSAN=1 # Bazel's compiler - os: linux compiler: gcc - env: UBUNTU=15.10 COMPILER=bazel NO_ASAN=1 NO_VALGRIND=1 + env: UBUNTU=15.10 COMPILER=bazel NO_UBSAN=1 NO_VALGRIND=1 # Ubuntu 14.04 # GCC - os: linux compiler: gcc - # ASAN (aka '-fsanitize=undefined,address') is not supported in GCC 4.8. - env: UBUNTU=14.04 COMPILER=gcc-4.8 NO_ASAN=1 + # UBSan (aka '-fsanitize=undefined') is not supported in GCC 4.8. + env: UBUNTU=14.04 COMPILER=gcc-4.8 NO_UBSAN=1 - os: linux compiler: gcc env: UBUNTU=14.04 COMPILER=gcc-5 @@ -90,45 +91,46 @@ matrix: env: UBUNTU=14.04 COMPILER=clang-3.5 STL=libc++ - os: linux compiler: clang - # ASAN is disabled because Ubuntu Trusty uses libc++ 1.x that doesn't work - # with ASAN, it fails with this error: + # UBSan is disabled because Ubuntu Trusty uses libc++ 1.x that doesn't work + # with UBSan, it fails with this error: # /usr/include/c++/v1/memory:1550:35: runtime error: null pointer passed as argument 2, which is declared to never be null - env: UBUNTU=14.04 COMPILER=clang-3.8 STL=libc++ NO_ASAN=1 + env: UBUNTU=14.04 COMPILER=clang-3.8 STL=libc++ NO_UBSAN=1 # OS X # GCC - os: osx compiler: gcc - # ASAN (aka '-fsanitize=undefined,address') is not supported in GCC 4.8. - env: COMPILER=gcc-4.8 NO_ASAN=1 + # UBSan (aka '-fsanitize=undefined') is not supported in GCC 4.8. + env: COMPILER=gcc-4.8 NO_UBSAN=1 - os: osx compiler: gcc env: COMPILER=gcc-5 # Clang on OS X (with libc++) - os: osx compiler: clang - # ASAN is disabled because it would hit this error: + # UBSan is disabled because it would hit this error: # ld: file not found: [...]/libclang_rt.ubsan_osx.a # Not sure if that's a limitation of Clang 3.6 on OS X or just of the brew-provided binaries. - env: COMPILER=clang-3.6 STL=libc++ NO_ASAN=1 + env: COMPILER=clang-3.6 STL=libc++ NO_UBSAN=1 - os: osx compiler: clang - # ASAN is disabled because it would hit this error: + # UBSan is disabled because it would hit this error: # ld: file not found: [...]/libclang_rt.ubsan_osx.a # Not sure if that's a limitation of Clang 3.7 on OS X or just of the brew-provided binaries. - env: COMPILER=clang-3.7 STL=libc++ NO_ASAN=1 + env: COMPILER=clang-3.7 STL=libc++ NO_UBSAN=1 # AppleClang on OS X (with libc++) - os: osx compiler: clang # OS X 10.10 osx_image: xcode7.1 - # ASAN is disabled because AppleClang does not support -fsanitize=undefined. - env: COMPILER=clang-default STL=libc++ NO_ASAN=1 + # UBSan is disabled because AppleClang does not support -fsanitize=undefined. + env: COMPILER=clang-default STL=libc++ NO_UBSAN=1 - os: osx compiler: clang # OS X 10.11 osx_image: xcode7.3 - env: COMPILER=clang-default STL=libc++ + # UBSan is disabled because AppleClang does not support -fsanitize=undefined. + env: COMPILER=clang-default STL=libc++ NO_UBSAN=1 # Disabled combinations: # @@ -150,13 +152,13 @@ matrix: # adding explicit casts to the exact types of the expected overload. # - os: osx # compiler: clang -# env: COMPILER=clang MY_CXX=clang++ STL=libc++ NO_ASAN=1 +# env: COMPILER=clang MY_CXX=clang++ STL=libc++ NO_ASAN=1 NO_UBSAN=1 # # This triggers an assert error in the compiler, with the message: # "expected to get called on an inlined function!" [...] function isMSExternInline, file Decl.cpp, line 2647. # - os: osx # compiler: clang -# env: COMPILER=clang-3.5 MY_CXX=clang++-3.5 STL=libc++ NO_VALGRIND=1 NO_ASAN=1 +# env: COMPILER=clang-3.5 MY_CXX=clang++-3.5 STL=libc++ NO_VALGRIND=1 NO_ASAN=1 NO_UBSAN=1 # # This fails with this error: # /usr/include/c++/v1/string:1938:44: error: 'basic_string<_CharT, _Traits, _Allocator>' is missing @@ -164,4 +166,4 @@ matrix: # TODO: Try again every once in a while (to re-enable these once the bug in libc++ is fixed). # - os: linux # compiler: clang -# env: UBUNTU=16.04 COMPILER=clang-3.8 STL=libc++ NO_ASAN=1 +# env: UBUNTU=16.04 COMPILER=clang-3.8 STL=libc++ NO_ASAN=1 NO_UBSAN=1 diff --git a/CMakeLists.txt b/CMakeLists.txt index 8357ee25..fc24e3c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,18 +38,6 @@ if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") endif() set(RUN_TESTS_UNDER_VALGRIND FALSE CACHE BOOL "Whether to run Fruit tests under valgrind") -set(INSTRUMENT_WITH_SANITIZERS FALSE CACHE BOOL "Whether to instrument code with code sanitizers") -if (${RUN_TESTS_UNDER_VALGRIND} AND ${INSTRUMENT_WITH_SANITIZERS}) - message(FATAL_ERROR "At most one of RUN_TESTS_UNDER_VALGRIND and INSTRUMENT_WITH_SANITIZERS can be used, but both were specified.") -endif() -if(${INSTRUMENT_WITH_SANITIZERS}) - if("${CMAKE_CXX_COMPILER_ID}" MATCHES "^(GNU|Clang|Intel|AppleClang)$") - set(FRUIT_ADDITIONAL_COMPILE_FLAGS "${FRUIT_ADDITIONAL_COMPILE_FLAGS} -fsanitize=undefined,address") - set(FRUIT_ADDITIONAL_LINKER_FLAGS "${FRUIT_ADDITIONAL_LINKER_FLAGS} -fsanitize=undefined,address") - elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "^(MSVC)$") - message(FATAL_ERROR "INSTRUMENT_WITH_SANITIZERS is not supported with MSVC") - endif() -endif() add_definitions(${FRUIT_ADDITIONAL_COMPILE_FLAGS}) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FRUIT_ADDITIONAL_LINKER_FLAGS}") diff --git a/extras/scripts/postsubmit-helper.sh b/extras/scripts/postsubmit-helper.sh index 6c08c613..3668d23f 100755 --- a/extras/scripts/postsubmit-helper.sh +++ b/extras/scripts/postsubmit-helper.sh @@ -72,7 +72,8 @@ then case "$1" in DebugPlain) CMAKE_ARGS=(-DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="$STLARG -O2") ;; - DebugAsan) CMAKE_ARGS=(-DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="$STLARG -O0" -DINSTRUMENT_WITH_SANITIZERS=TRUE) ;; + DebugAsan) CMAKE_ARGS=(-DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="$STLARG -O0 -fsanitize=address") ;; + DebugAsanUbsan) CMAKE_ARGS=(-DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="$STLARG -O0 -fsanitize=address,undefined") ;; DebugValgrind) CMAKE_ARGS=(-DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="$STLARG -O2" -DRUN_TESTS_UNDER_VALGRIND=TRUE) ;; ReleasePlain) CMAKE_ARGS=(-DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="$STLARG -Werror") ;; ReleaseValgrind) CMAKE_ARGS=(-DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="$STLARG -Werror" -DRUN_TESTS_UNDER_VALGRIND=TRUE) ;;