Skip to content

Commit 5d744e9

Browse files
committed
Auto merge of #44410 - alexcrichton:fix-travis, r=Mark-Simulacrum
Fix sanitizer tests on buggy kernels Travis recently pushed an update to the Linux environments, namely the kernels that we're running on. This in turn caused some of the sanitizer tests we run to fail. We also apparently weren't the first to hit these failures! Detailed in google/sanitizers#837 these tests were failing due to a specific commit in the kernel which has since been backed out, but for now work around the buggy kernel that's deployed on Travis and eventually we should be able to remove these flags.
2 parents a0b3419 + 43efcce commit 5d744e9

File tree

4 files changed

+31
-14
lines changed

4 files changed

+31
-14
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
language: shell
22
sudo: required
33
dist: trusty
4-
# FIXME(#44398) shouldn't need to be here
5-
group: deprecated-2017Q3
64
services:
75
- docker
86

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
-include ../tools.mk
22

3+
LOG := $(TMPDIR)/log.txt
4+
35
# NOTE the address sanitizer only supports x86_64 linux and macOS
46

57
ifeq ($(TARGET),x86_64-apple-darwin)
@@ -8,12 +10,21 @@ EXTRA_RUSTFLAG=-C rpath
810
else
911
ifeq ($(TARGET),x86_64-unknown-linux-gnu)
1012
ASAN_SUPPORT=$(SANITIZER_SUPPORT)
11-
EXTRA_RUSTFLAG=
13+
14+
# Apparently there are very specific Linux kernels, notably the one that's
15+
# currently on Travis CI, which contain a buggy commit that triggers failures in
16+
# the ASan implementation, detailed at google/sanitizers#837. As noted in
17+
# google/sanitizers#856 the "fix" is to avoid using PIE binaries, so we pass a
18+
# different relocation model to avoid generating a PIE binary. Once Travis is no
19+
# longer running kernel 4.4.0-93 we can remove this and pass an empty set of
20+
# flags again.
21+
EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic
1222
endif
1323
endif
1424

1525
all:
1626
ifeq ($(ASAN_SUPPORT),1)
1727
$(RUSTC) -g -Z sanitizer=address -Z print-link-args $(EXTRA_RUSTFLAG) overflow.rs | grep -q librustc_asan
18-
$(TMPDIR)/overflow 2>&1 | grep -q stack-buffer-overflow
28+
$(TMPDIR)/overflow 2>&1 | tee $(LOG)
29+
grep -q stack-buffer-overflow $(LOG)
1930
endif

src/test/run-make/sanitizer-cdylib-link/Makefile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
-include ../tools.mk
22

3+
LOG := $(TMPDIR)/log.txt
4+
35
# This test builds a shared object, then an executable that links it as a native
46
# rust library (constrast to an rlib). The shared library and executable both
57
# are compiled with address sanitizer, and we assert that a fault in the cdylib
68
# is correctly detected.
79

810
ifeq ($(TARGET),x86_64-unknown-linux-gnu)
911
ASAN_SUPPORT=$(SANITIZER_SUPPORT)
10-
EXTRA_RUSTFLAG=
12+
13+
# See comment in sanitizer-address/Makefile for why this is here
14+
EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic
1115
endif
1216

1317
all:
1418
ifeq ($(ASAN_SUPPORT),1)
15-
$(RUSTC) -g -Z sanitizer=address --crate-type cdylib --target $(TARGET) library.rs
16-
$(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) -llibrary program.rs
17-
LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | grep -q stack-buffer-overflow
19+
$(RUSTC) -g -Z sanitizer=address --crate-type cdylib --target $(TARGET) $(EXTRA_RUSTFLAG) library.rs
20+
$(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) $(EXTRA_RUSTFLAG) -llibrary program.rs
21+
LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | tee $(LOG)
22+
grep -q stack-buffer-overflow $(LOG)
1823
endif
19-

src/test/run-make/sanitizer-dylib-link/Makefile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
-include ../tools.mk
22

3+
LOG := $(TMPDIR)/log.txt
4+
35
# This test builds a shared object, then an executable that links it as a native
46
# rust library (constrast to an rlib). The shared library and executable both
57
# are compiled with address sanitizer, and we assert that a fault in the dylib
68
# is correctly detected.
79

810
ifeq ($(TARGET),x86_64-unknown-linux-gnu)
911
ASAN_SUPPORT=$(SANITIZER_SUPPORT)
10-
EXTRA_RUSTFLAG=
12+
13+
# See comment in sanitizer-address/Makefile for why this is here
14+
EXTRA_RUSTFLAG=-C relocation-model=dynamic-no-pic
1115
endif
1216

1317
all:
1418
ifeq ($(ASAN_SUPPORT),1)
15-
$(RUSTC) -g -Z sanitizer=address --crate-type dylib --target $(TARGET) library.rs
16-
$(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) -llibrary program.rs
17-
LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | grep -q stack-buffer-overflow
19+
$(RUSTC) -g -Z sanitizer=address --crate-type dylib --target $(TARGET) $(EXTRA_RUSTFLAG) library.rs
20+
$(RUSTC) -g -Z sanitizer=address --crate-type bin --target $(TARGET) $(EXTRA_RUSTFLAG) -llibrary program.rs
21+
LD_LIBRARY_PATH=$(TMPDIR) $(TMPDIR)/program 2>&1 | tee $(LOG)
22+
grep -q stack-buffer-overflow $(LOG)
1823
endif
19-

0 commit comments

Comments
 (0)