From bdbaf376e297978a8d4206a5a860c88e5b2b2428 Mon Sep 17 00:00:00 2001 From: Derek Mauro Date: Wed, 5 Mar 2025 10:14:08 -0800 Subject: [PATCH] UBSAN: Use -fno-sanitize-recover -fno-sanitize-recover will cause tests that encounter undefined behavior to abort and fail, instead of just logging an error message. PiperOrigin-RevId: 733779444 Change-Id: I3f88aef8f91d64572e9d46ad8f6cc40562f25a30 --- ci/linux_clang-latest_libcxx_asan_bazel.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ci/linux_clang-latest_libcxx_asan_bazel.sh b/ci/linux_clang-latest_libcxx_asan_bazel.sh index a66e7772bee..a47fd1bdc3f 100755 --- a/ci/linux_clang-latest_libcxx_asan_bazel.sh +++ b/ci/linux_clang-latest_libcxx_asan_bazel.sh @@ -59,6 +59,9 @@ if [[ ${KOKORO_GFILE_DIR:-} ]] && [[ -d "${KOKORO_GFILE_DIR}/distdir" ]]; then BAZEL_EXTRA_ARGS="--distdir=/distdir ${BAZEL_EXTRA_ARGS:-}" fi +# https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#available-checks +readonly UBSAN_CHECKS="float-divide-by-zero,nullability,undefined" + for std in ${STD}; do for compilation_mode in ${COMPILATION_MODE}; do for exceptions_mode in ${EXCEPTIONS_MODE}; do @@ -79,9 +82,8 @@ for std in ${STD}; do --copt="${exceptions_mode}" \ --copt="-DGTEST_REMOVE_LEGACY_TEST_CASEAPI_=1" \ --copt="-fsanitize=address" \ - --copt="-fsanitize=float-divide-by-zero" \ - --copt="-fsanitize=nullability" \ - --copt="-fsanitize=undefined" \ + --copt="-fsanitize=${UBSAN_CHECKS}" \ + --copt="-fno-sanitize-recover=${UBSAN_CHECKS}" \ --copt="-fno-sanitize-blacklist" \ --copt=-Werror \ --enable_bzlmod=true \