diff --git a/.bazelrc b/.bazelrc index caa7b128f..733ef5e3b 100644 --- a/.bazelrc +++ b/.bazelrc @@ -30,6 +30,16 @@ build:clang-asan-strict --config=clang-asan build:clang-asan-strict --copt -fsanitize=integer build:clang-asan-strict --linkopt -fsanitize=integer +# Use Clang compiler with Thread Sanitizer. +build:clang-tsan --config=clang +build:clang-tsan --copt -DTHREAD_SANITIZER=1 +build:clang-tsan --copt -O1 +build:clang-tsan --copt -fno-omit-frame-pointer +build:clang-tsan --copt -fno-optimize-sibling-calls +build:clang-tsan --copt -fsanitize=thread +build:clang-tsan --linkopt -fsanitize=thread +build:clang-tsan --linkopt -fuse-ld=lld + # Use GCC compiler. build:gcc --action_env=BAZEL_COMPILER=gcc build:gcc --action_env=CC=gcc diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e744b836c..b5b07e408 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -102,6 +102,12 @@ jobs: arch: x86_64 action: test flags: --config=clang-asan-strict --define=crypto=system + - name: 'NullVM on Linux/x86_64 with TSan' + engine: 'null' + os: ubuntu-20.04 + arch: x86_64 + action: test + flags: --config=clang-tsan - name: 'NullVM on Windows/x86_64' engine: 'null' os: windows-2019 @@ -123,6 +129,14 @@ jobs: action: test flags: --config=clang-asan cache: true + - name: 'V8 on Linux/x86_64 with TSan' + engine: 'v8' + repo: 'v8' + os: ubuntu-20.04 + arch: x86_64 + action: test + flags: --config=clang-tsan + cache: true - name: 'V8 on Linux/aarch64' engine: 'v8' repo: 'v8' diff --git a/test/runtime_test.cc b/test/runtime_test.cc index 061ab5ed0..92ef4c28b 100644 --- a/test/runtime_test.cc +++ b/test/runtime_test.cc @@ -128,7 +128,14 @@ TEST_P(TestVM, CloneUntilOutOfMemory) { // Prevent clone from droping out of scope and freeing memory. clones.push_back(std::move(clone)); } - EXPECT_GE(clones.size(), 1000); + + size_t min_clones = 1000; +#if defined(__has_feature) +#if __has_feature(thread_sanitizer) + min_clones = 100; +#endif +#endif + EXPECT_GE(clones.size(), min_clones); } #endif