summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2020-11-01 13:09:59 -0500
committerBen Gamari <ben@smart-cactus.org>2020-11-01 13:09:59 -0500
commitb4686bff56377a583f0605b81fae290d3fee4c4a (patch)
tree943f41fa5dcac0a6ce4f434135c36b1d0a06cea2
parentdffd943207dd356a113ee8ff3e51227c2655a039 (diff)
parentf7e6f012bcedbf60fac2631e223b8766c9afa959 (diff)
downloadhaskell-b4686bff56377a583f0605b81fae290d3fee4c4a.tar.gz
Merge branch 'wip/tsan/ci' into wip/tsan/all
-rw-r--r--.gitlab-ci.yml19
-rw-r--r--hadrian/src/Flavour.hs1
-rw-r--r--includes/rts/TSANUtils.h4
-rw-r--r--testsuite/driver/testglobals.py3
-rw-r--r--testsuite/driver/testlib.py7
-rw-r--r--testsuite/tests/concurrent/should_run/all.T1
-rw-r--r--testsuite/tests/dynlibs/all.T12
-rw-r--r--testsuite/tests/hiefile/should_compile/all.T1
-rw-r--r--testsuite/tests/perf/compiler/all.T9
-rw-r--r--testsuite/tests/rts/all.T4
10 files changed, 55 insertions, 6 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 796145dc45..fe96216272 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -681,6 +681,25 @@ nightly-x86_64-linux-deb9-integer-simple:
TEST_ENV: "x86_64-linux-deb9-integer-simple"
TEST_TYPE: slowtest
+.build-x86_64-linux-deb9-tsan:
+ extends: .validate-linux-hadrian
+ stage: full-build
+ variables:
+ TEST_ENV: "x86_64-linux-deb9-tsan"
+ BUILD_FLAVOUR: "thread-sanitizer"
+ TSAN_OPTIONS: "suppressions=$CI_PROJECT_DIR/rts/.tsan-suppressions"
+ # Haddock is large enough to make TSAN choke without massive quantities of
+ # memory.
+ HADRIAN_ARGS: "--docs=none"
+
+nightly-x86_64-linux-deb9-tsan:
+ <<: *nightly
+ extends: .build-x86_64-linux-deb9-tsan
+
+validate-x86_64-linux-deb9-tsan:
+ extends: .build-x86_64-linux-deb9-tsan
+ when: manual
+
validate-x86_64-linux-deb9-dwarf:
extends: .build-x86_64-linux-deb9
stage: full-build
diff --git a/hadrian/src/Flavour.hs b/hadrian/src/Flavour.hs
index 0a4439827f..d2adbe356e 100644
--- a/hadrian/src/Flavour.hs
+++ b/hadrian/src/Flavour.hs
@@ -124,4 +124,5 @@ enableThreadSanitizer = addArgs $ mconcat
, builder (Ghc LinkHs) ? arg "-optl-fsanitize=thread"
, builder (Cc CompileC) ? (arg "-fsanitize=thread" <> arg "-DTSAN_ENABLED")
, builder (Cabal Flags) ? arg "thread-sanitizer"
+ , builder RunTest ? arg "--config=have_thread_sanitizer=True"
]
diff --git a/includes/rts/TSANUtils.h b/includes/rts/TSANUtils.h
index 00f226d9c6..72f4541a89 100644
--- a/includes/rts/TSANUtils.h
+++ b/includes/rts/TSANUtils.h
@@ -40,6 +40,10 @@
#endif
#if defined(TSAN_ENABLED)
+#if !defined(HAVE_C11_ATOMICS)
+#error TSAN cannot be enabled without C11 atomics suppoort.
+#endif
+
#define TSAN_ANNOTATE_HAPPENS_BEFORE(addr) \
AnnotateHappensBefore(__FILE__, __LINE__, (void*)(addr))
#define TSAN_ANNOTATE_HAPPENS_AFTER(addr) \
diff --git a/testsuite/driver/testglobals.py b/testsuite/driver/testglobals.py
index 30b457e829..aa3bc4c4ff 100644
--- a/testsuite/driver/testglobals.py
+++ b/testsuite/driver/testglobals.py
@@ -151,6 +151,9 @@ class TestConfig:
# Is the compiler dynamically linked?
self.ghc_dynamic = False
+ # Are we running in a ThreadSanitizer-instrumented build?
+ self.have_thread_sanitizer = False
+
# Do symbols use leading underscores?
self.leading_underscore = False
diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py
index 15bcdde0eb..1a1c908fc3 100644
--- a/testsuite/driver/testlib.py
+++ b/testsuite/driver/testlib.py
@@ -578,6 +578,9 @@ def have_slow_bignum( ) -> bool:
def llvm_build ( ) -> bool:
return config.ghc_built_by_llvm
+def have_thread_sanitizer( ) -> bool:
+ return config.have_thread_sanitizer
+
# ---
# Note [Measuring residency]
@@ -629,6 +632,10 @@ def collect_compiler_residency(tolerance_pct: float):
def high_memory_usage(name, opts):
opts.alone = True
+ # ThreadSanitizer significantly increases memory footprint; skip
+ if have_thread_sanitizer():
+ opts.skip = True
+
# If a test is for a multi-CPU race, then running the test alone
# increases the chance that we'll actually see it.
def multi_cpu_race(name, opts):
diff --git a/testsuite/tests/concurrent/should_run/all.T b/testsuite/tests/concurrent/should_run/all.T
index 9297c5890e..2b8375e61e 100644
--- a/testsuite/tests/concurrent/should_run/all.T
+++ b/testsuite/tests/concurrent/should_run/all.T
@@ -245,6 +245,7 @@ test('conc068', [ omit_ways(concurrent_ways), exit_code(1) ], compile_and_run, [
test('setnumcapabilities001',
[ only_ways(['threaded1','threaded2', 'nonmoving_thr']),
extra_run_opts('8 12 2000'),
+ when(have_thread_sanitizer(), expect_broken(18808)),
req_smp ],
compile_and_run, [''])
diff --git a/testsuite/tests/dynlibs/all.T b/testsuite/tests/dynlibs/all.T
index b7272d4bac..092c983389 100644
--- a/testsuite/tests/dynlibs/all.T
+++ b/testsuite/tests/dynlibs/all.T
@@ -1,12 +1,18 @@
-
-test('T3807', [req_shared_libs, when(opsys('mingw32'), skip)], makefile_test, [])
+test('T3807',
+ [req_shared_libs,
+ when(have_thread_sanitizer(), expect_broken(18883)),
+ when(opsys('mingw32'),
+ skip)], makefile_test, [])
test('T4464', [req_shared_libs, unless(opsys('mingw32'), skip)], makefile_test, [])
test('T5373', [req_shared_libs], makefile_test, [])
# It's not clear exactly what platforms we can expect this to succeed on.
-test('T13702', unless(opsys('linux'), skip), makefile_test, [])
+test('T13702',
+ [when(have_thread_sanitizer(), expect_broken(18884)),
+ unless(opsys('linux'), skip)],
+ makefile_test, [])
# test that -shared and -flink-rts actually links the rts
test('T18072', [req_shared_libs, unless(opsys('linux'), skip)], makefile_test, [])
diff --git a/testsuite/tests/hiefile/should_compile/all.T b/testsuite/tests/hiefile/should_compile/all.T
index a98a042ca0..489cff28d0 100644
--- a/testsuite/tests/hiefile/should_compile/all.T
+++ b/testsuite/tests/hiefile/should_compile/all.T
@@ -4,6 +4,7 @@ test('hie002',
when(wordsize(32), skip),
# No linting in perf tests:
no_lint,
+ high_memory_usage,
collect_compiler_stats('bytes allocated',10)],
compile,
['-fno-code -fwrite-ide-info'])
diff --git a/testsuite/tests/perf/compiler/all.T b/testsuite/tests/perf/compiler/all.T
index 090dbb4acf..0b9cd2fec3 100644
--- a/testsuite/tests/perf/compiler/all.T
+++ b/testsuite/tests/perf/compiler/all.T
@@ -132,20 +132,23 @@ test('T9675',
test('T9872a',
[ only_ways(['normal']),
- collect_compiler_stats('bytes allocated', 1)
+ collect_compiler_stats('bytes allocated', 1),
+ high_memory_usage
],
compile_fail,
[''])
test('T9872b',
[ only_ways(['normal']),
- collect_compiler_stats('bytes allocated', 1)
+ collect_compiler_stats('bytes allocated', 1),
+ high_memory_usage
],
compile_fail,
[''])
test('T9872c',
[ only_ways(['normal']),
- collect_compiler_stats('bytes allocated', 1)
+ collect_compiler_stats('bytes allocated', 1),
+ high_memory_usage
],
compile_fail,
[''])
diff --git a/testsuite/tests/rts/all.T b/testsuite/tests/rts/all.T
index e469783e80..62c893cde1 100644
--- a/testsuite/tests/rts/all.T
+++ b/testsuite/tests/rts/all.T
@@ -38,6 +38,8 @@ test('derefnull',
when(platform('i386-apple-darwin'), [ignore_stderr, exit_code(139)]),
when(platform('x86_64-apple-darwin'), [ignore_stderr, exit_code(139)]),
when(opsys('mingw32'), [ignore_stderr, exit_code(11)]),
+ # ThreadSanitizer changes the output
+ when(have_thread_sanitizer(), skip),
# since these test are supposed to crash the
# profile report will be empty always.
# so disable the check for profiling
@@ -64,6 +66,8 @@ test('divbyzero',
# The output under OS X is too unstable to readily compare
when(platform('i386-apple-darwin'), [ignore_stderr, exit_code(136)]),
when(platform('x86_64-apple-darwin'), [ignore_stderr, exit_code(136)]),
+ # ThreadSanitizer changes the output
+ when(have_thread_sanitizer(), skip),
# since these test are supposed to crash the
# profile report will be empty always.
# so disable the check for profiling