Skip to content

Commit

Permalink
Fix Travis TSAN build
Browse files Browse the repository at this point in the history
Travis upgraded the trusty image that tests use and it broke our TSAN
tests. TSAN does not work for pie binaries on the upgraded OS. See
google/sanitizers#503
The fix is to use gcc-5 and non-pie binaries.

Change-Id: I9b972f1c08fb7408d5bcc54b403660c1255a11d5
  • Loading branch information
gurgenh committed Aug 22, 2016
1 parent c3153b2 commit 0cd53ae
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ addons:
packages:
- g++-4.8
- gcc-4.8
# We need gcc-5 for TSAN. See comments in tools/bazel.rc.
- g++-5
- gcc-5
- lcov
- libio-socket-ssl-perl
- oracle-java8-installer
Expand All @@ -30,8 +33,8 @@ env:
- SCENARIO="build-and-test"
# Build & run the tests with ASAN enabled
- SCENARIO="asan"
# Build & run the tests with TSAN enabled
- SCENARIO="tsan"
# Build & run the tests with TSAN enabled (using gcc-5)
- SCENARIO="tsan" CC=gcc-5 CXX=g++-5
# Build & run the tests & generate coverage report
- SCENARIO="coverage"
# Build & run docker tests
Expand Down
4 changes: 4 additions & 0 deletions script/presubmits
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ function tsan() {
build_and_test 'tsan' || return 1
}

function tsan_nopie() {
build_and_test 'tsan_nopie' || return 1
}

function release() {
build_and_test 'release' || return 1
}
Expand Down
2 changes: 1 addition & 1 deletion script/travis/run
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ SCENARIO="$1"
case $SCENARIO in
build-and-test) build_and_test || error_exit "Build and Tests failed";;
asan) asan || error_exit "ASAN tests failed";;
tsan) tsan || error_exit "TSAN tests failed";;
tsan) tsan_nopie || error_exit "TSAN tests failed";;
coverage) coverage || error_exit "Coverage failed";;
docker-tests) docker_tests || error_exit "Docker tests failed";;
*) error_exit "Usage: travis-run build-and-test|asan|tsan|coverage|docker-tests";;
Expand Down
15 changes: 13 additions & 2 deletions tools/bazel.rc
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,21 @@ build:tsan --copt -fno-omit-frame-pointer
build:tsan --linkopt -fsanitize=thread
build:tsan --linkopt -pie
# Use -Wl,-ltsan instead of -ltsan to make Bazel link libtsan before all other
# libs. TSAN on Ubuntu 12.04 (used by Travis) doesn't work if -lpthread is
# specified before -ltsan.
# libs in particularly before -lpthread. This allows TSAN to pull in it's own
# version of -lpthread.
build:tsan --linkopt -Wl,-ltsan

# Our default TSAN setup with -pie does not work with some linux versions (e.g.,
# on Travis's trusty). See https://github.com/google/sanitizers/issues/503
# So for TSAN on Travis we use gcc-5, which supports TSAN for non-pie binaries.
build:tsan_nopie --strip=never
build:tsan_nopie --copt -fsanitize=thread
build:tsan_nopie --copt -O2
build:tsan_nopie --copt -g
build:tsan_nopie --copt -fno-omit-frame-pointer
build:tsan_nopie --linkopt -fsanitize=thread
build:tsan_nopie --linkopt -Wl,-ltsan

# Release builds
build:release -c opt

Expand Down

0 comments on commit 0cd53ae

Please sign in to comment.