THRIFT-2026: Eliminate some undefined behavior in C/C++
Clients: glib, C++
Patch: Jim Apple <jbapple-impala@apache.org>
This closes #1214
This patch fixes some undefined behavior were found using Clang's
UndefinedBehaviorSanitizer (UBSan). To check for undefined behavior,
run /build/docker/scripts/ubsan.sh. This is run during CI builds, as
well.
The examples of the types of undefined behavior fixed in this commit
are:
1. Enumerations exhibit undefined behavior when they have values
outside of a range dependent on the values of their enumerators, as
specified in C++14's chapter 7.2 ("Enumeration declarations"),
paragraph 8.
2. Left shift of negative values, used in zigzag encoding, is
undefined behavior. See 5.8 ("Shift operators"), paragraph 2 for
C++ and 6.5.7 ("Bitwise shift operators"), paragraph 4 for C99 and
C11.
diff --git a/.travis.yml b/.travis.yml
index 70293ed..10c6fd0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -152,6 +152,12 @@
BUILD_ENV="-e CC=gcc -e CXX=g++"
DISTRO=debian
+ # C and C++ undefined behavior. This wraps autotools.sh, but each binary crashes if
+ # undefined behavior occurs. Skips the known flaky tests.
+ - TEST_NAME="UBSan"
+ SCRIPT="ubsan.sh"
+ BUILD_ARG="--without-haskell --without-nodejs --without-perl --without-python"
+
matrix:
include:
# QA jobs for code analytics and metrics