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
This commit is contained in:
Derek Mauro
2025-03-05 10:14:08 -08:00
committed by Copybara-Service
parent e59348319d
commit bdbaf376e2

View File

@@ -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 \