Skip to content

Commit

Permalink
Enable ASAN (but not UBSan) in all OS/compiler combinations ran in Tr…
Browse files Browse the repository at this point in the history
…avis CI where ASAN/UBSan were previously disabled.

Some of these will probably fail, and will be disabled again.
  • Loading branch information
poletti-marco committed May 26, 2016
1 parent 0a9f279 commit 982f470
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 37 deletions.
50 changes: 26 additions & 24 deletions .travis.yml
Expand Up @@ -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'

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
#
Expand All @@ -150,18 +152,18 @@ 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
# exception specification 'noexcept(is_nothrow_copy_constructible<allocator_type>::value)'
# 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
12 changes: 0 additions & 12 deletions CMakeLists.txt
Expand Up @@ -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}")
Expand Down
3 changes: 2 additions & 1 deletion extras/scripts/postsubmit-helper.sh
Expand Up @@ -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) ;;
Expand Down

0 comments on commit 982f470

Please sign in to comment.