From 57ba578001a8c95d9d83939cb2d2e820c09e34c2 Mon Sep 17 00:00:00 2001 From: Brian Pane Date: Thu, 25 Jan 2018 16:58:08 +0000 Subject: [PATCH] bazel: fix protobuf UBSAN errors *Description*: The google-protobuf library, by default, uses unaligned reads on x86. Those happen to work on that CPU architecture, but their behavior is undefined in C/C++, so UBSAN (which runs along with ASAN in the CI ASAN tests) treats them as an error. Defining `ADDRESS_SANITIZER=1` causes the protobuf library to use a portable alternative to the unaligned reads. Signed-off-by: Brian Pane *Risk Level*: Low *Testing*: I tested this change with PR [2429](https://github.com/envoyproxy/envoy/pull/2429), where it fixed the ASAN test failure. *Docs Changes*: N/A *Release Notes*: N/A --- tools/bazel.rc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/bazel.rc b/tools/bazel.rc index 16a50c93a4b26..e8bf79cc84b56 100644 --- a/tools/bazel.rc +++ b/tools/bazel.rc @@ -13,8 +13,9 @@ build:asan --define tcmalloc=disabled build:asan --build_tag_filters=-no_asan build:asan --test_tag_filters=-no_asan build:asan --define signal_trace=disabled +build:asan --copt -DADDRESS_SANITIZER=1 -# Clang 5.0 ASAN +# Clang 5.0 ASAN/UBSAN build:clang-asan --define ENVOY_CONFIG_ASAN=1 build:clang-asan --copt -D__SANITIZE_ADDRESS__ build:clang-asan --copt -fsanitize=address,undefined @@ -27,6 +28,7 @@ build:clang-asan --define tcmalloc=disabled build:clang-asan --build_tag_filters=-no_asan build:clang-asan --test_tag_filters=-no_asan build:clang-asan --define signal_trace=disabled +build:clang-asan --copt -DADDRESS_SANITIZER=1 build:clang-asan --test_env=ASAN_SYMBOLIZER_PATH # Clang 5.0 TSAN