diff --git a/.bazelrc b/.bazelrc index a344955a0..caa7b128f 100644 --- a/.bazelrc +++ b/.bazelrc @@ -8,6 +8,28 @@ build:clang --action_env=BAZEL_COMPILER=clang build:clang --action_env=CC=clang build:clang --action_env=CXX=clang++ +# Use Clang compiler with Address and Undefined Behavior Sanitizers. +build:clang-asan --config=clang +build:clang-asan --copt -DADDRESS_SANITIZER=1 +build:clang-asan --copt -DUNDEFINED_SANITIZER=1 +build:clang-asan --copt -O1 +build:clang-asan --copt -fno-omit-frame-pointer +build:clang-asan --copt -fno-optimize-sibling-calls +build:clang-asan --copt -fsanitize=address,undefined +build:clang-asan --copt -fsanitize-address-use-after-scope +build:clang-asan --linkopt -fsanitize=address,undefined +build:clang-asan --linkopt -fsanitize-address-use-after-scope +build:clang-asan --linkopt -fsanitize-link-c++-runtime +build:clang-asan --linkopt -fuse-ld=lld +build:clang-asan --test_env=ASAN_OPTIONS=check_initialization_order=1:detect_stack_use_after_return=1:strict_init_order=1:strict_string_checks=1 +build:clang-asan --test_env=UBSAN_OPTIONS=halt_on_error=1:print_stacktrace=1 +build:clang-asan --test_env=ASAN_SYMBOLIZER_PATH + +# Use Clang compiler with Address and Undefined Behavior Sanitizers (strict version). +build:clang-asan-strict --config=clang-asan +build:clang-asan-strict --copt -fsanitize=integer +build:clang-asan-strict --linkopt -fsanitize=integer + # 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 f7e43b8bb..e744b836c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -96,6 +96,12 @@ jobs: arch: x86_64 action: test flags: --config=gcc + - name: 'NullVM on Linux/x86_64 with ASan' + engine: 'null' + os: ubuntu-20.04 + arch: x86_64 + action: test + flags: --config=clang-asan-strict --define=crypto=system - name: 'NullVM on Windows/x86_64' engine: 'null' os: windows-2019 @@ -109,6 +115,14 @@ jobs: action: test flags: --config=clang --define=crypto=system cache: true + - name: 'V8 on Linux/x86_64 with ASan' + engine: 'v8' + repo: 'v8' + os: ubuntu-20.04 + arch: x86_64 + action: test + flags: --config=clang-asan + cache: true - name: 'V8 on Linux/aarch64' engine: 'v8' repo: 'v8' @@ -145,6 +159,13 @@ jobs: arch: x86_64 action: test flags: --config=clang + - name: 'Wasmtime on Linux/x86_64 with ASan' + engine: 'wasmtime' + repo: 'com_github_bytecodealliance_wasmtime' + os: ubuntu-20.04 + arch: x86_64 + action: test + flags: --config=clang-asan-strict --define=crypto=system - name: 'Wasmtime on Linux/aarch64' engine: 'wasmtime' repo: 'com_github_bytecodealliance_wasmtime' diff --git a/test/runtime_test.cc b/test/runtime_test.cc index 79e672164..061ab5ed0 100644 --- a/test/runtime_test.cc +++ b/test/runtime_test.cc @@ -107,8 +107,15 @@ TEST_P(TestVM, CloneUntilOutOfMemory) { ASSERT_TRUE(vm_->load(source, {}, {})); ASSERT_TRUE(vm_->link("")); + size_t max_clones = 100000; +#if defined(__has_feature) +#if __has_feature(address_sanitizer) + max_clones = 1000; +#endif +#endif + std::vector> clones; - for (;;) { + for (size_t i = 0; i < max_clones; i++) { auto clone = vm_->clone(); if (clone == nullptr) { break;