IMPALA-5031: Suppress noisy UBSAN errors.
The current version of the standard C++ library that Impala is often
compiled with (libstdc++ 4.9.2) contains some undefined behavior. This
patch prevents that behavior from showing up in UBSAN errors.
The behavior in question is in violation of chapter 5 ("Expressions")
paragraph 4: "If during the evaluation of an expression, the result is
not mathematically defined or not in the range of representable values
for its type, the behavior is undefined." The bitwise complement of an
enumeration value does not necessarily produce another value of the
same enumeration, so the following can exhibit undefined behavior:
enum _Ios_Fmtflags {
_S_boolalpha = 1L << 0,
_S_dec = 1L << 1,
_S_fixed = 1L << 2,
_S_hex = 1L << 3,
_S_internal = 1L << 4,
_S_left = 1L << 5,
_S_oct = 1L << 6,
_S_right = 1L << 7,
_S_scientific = 1L << 8,
_S_showbase = 1L << 9,
_S_showpoint = 1L << 10,
_S_showpos = 1L << 11,
_S_skipws = 1L << 12,
_S_unitbuf = 1L << 13,
_S_uppercase = 1L << 14,
_S_adjustfield = _S_left | _S_right | _S_internal,
_S_basefield = _S_dec | _S_oct | _S_hex,
_S_floatfield = _S_scientific | _S_fixed,
_S_ios_fmtflags_end = 1L << 16
};
_Ios_Fmtflags operator~(_Ios_Fmtflags __a) {
return _Ios_Fmtflags(~static_cast<int>(__a));
}
This patch also fixes some omissions from the last UBSAN patch and
sets the UBSAN environment variables in all the useful locations.
Change-Id: Iac7a568ccc2d90ee174ccc286c108d0b28018fbb
Reviewed-on: http://gerrit.cloudera.org:8080/6378
Reviewed-by: Tim Armstrong <[email protected]>
Tested-by: Impala Public Jenkins
Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/b41c2114
Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/b41c2114
Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/b41c2114
Branch: refs/heads/master
Commit: b41c2114f42f92441e96b408a6864420c0d00cae
Parents: 5bb988b
Author: Jim Apple <[email protected]>
Authored: Sun Mar 5 16:40:15 2017 -0800
Committer: Impala Public Jenkins <[email protected]>
Committed: Fri Mar 17 19:57:08 2017 +0000
----------------------------------------------------------------------
bin/run-backend-tests.sh | 1 +
bin/start-impalad.sh | 3 ++-
bin/start-statestored.sh | 3 +++
bin/ubsan-suppressions.txt | 25 +++++++++++++++++++++++++
4 files changed, 31 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/b41c2114/bin/run-backend-tests.sh
----------------------------------------------------------------------
diff --git a/bin/run-backend-tests.sh b/bin/run-backend-tests.sh
index f426542..726db73 100755
--- a/bin/run-backend-tests.sh
+++ b/bin/run-backend-tests.sh
@@ -38,5 +38,6 @@ cd ..
export CTEST_OUTPUT_ON_FAILURE=1
export UBSAN_OPTIONS="print_stacktrace=1"
+UBSAN_OPTIONS="${UBSAN_OPTIONS}
suppressions=${IMPALA_HOME}/bin/ubsan-suppressions.txt"
export PATH="${IMPALA_TOOLCHAIN}/llvm-${IMPALA_LLVM_VERSION}/bin:${PATH}"
make test ARGS="${BE_TEST_ARGS}"
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/b41c2114/bin/start-impalad.sh
----------------------------------------------------------------------
diff --git a/bin/start-impalad.sh b/bin/start-impalad.sh
index a731804..a02b0ce 100755
--- a/bin/start-impalad.sh
+++ b/bin/start-impalad.sh
@@ -103,6 +103,7 @@ if ${CLUSTER_DIR}/admin is_kerberized; then
fi
. ${IMPALA_HOME}/bin/set-classpath.sh
-export UBSAN_OPTIONS='print_stacktrace=1'
+export UBSAN_OPTIONS="print_stacktrace=1"
+UBSAN_OPTIONS="${UBSAN_OPTIONS}
suppressions=${IMPALA_HOME}/bin/ubsan-suppressions.txt"
export PATH="${IMPALA_TOOLCHAIN}/llvm-${IMPALA_LLVM_VERSION}/bin:${PATH}"
exec ${TOOL_PREFIX} ${IMPALA_CMD} ${IMPALAD_ARGS}
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/b41c2114/bin/start-statestored.sh
----------------------------------------------------------------------
diff --git a/bin/start-statestored.sh b/bin/start-statestored.sh
index 75b676e..33f0dc1 100755
--- a/bin/start-statestored.sh
+++ b/bin/start-statestored.sh
@@ -59,4 +59,7 @@ if ${CLUSTER_DIR}/admin is_kerberized; then
fi
fi
+export UBSAN_OPTIONS="print_stacktrace=1"
+UBSAN_OPTIONS="${UBSAN_OPTIONS}
suppressions=${IMPALA_HOME}/bin/ubsan-suppressions.txt"
+export PATH="${IMPALA_TOOLCHAIN}/llvm-${IMPALA_LLVM_VERSION}/bin:${PATH}"
exec ${BINARY_BASE_DIR}/${BUILD_TYPE}/statestore/statestored
${STATESTORED_ARGS}
http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/b41c2114/bin/ubsan-suppressions.txt
----------------------------------------------------------------------
diff --git a/bin/ubsan-suppressions.txt b/bin/ubsan-suppressions.txt
new file mode 100644
index 0000000..8492607
--- /dev/null
+++ b/bin/ubsan-suppressions.txt
@@ -0,0 +1,25 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# This file suppresses UBSAN errors, following
+#
http://releases.llvm.org/3.8.0/tools/clang/docs/UndefinedBehaviorSanitizer.html#runtime-suppressions
+
+# Some methods in ios_base.h (libstdc++ 4.9.2) mask two values a and b of an
enum type to
+# create the logical equivalent of (a and (not b)) using the expression 'a &
~b'. When ~b
+# is not a valid enum member (and it usually isn't), this causes a UBSAN
error. The line
+# below suppresses that error.
+enum:ios_base.h