From a060c9f1090cf43bf84e853220f514fa96d3f774 Mon Sep 17 00:00:00 2001 From: Chen Bainian Date: Thu, 18 Jun 2020 10:51:31 +0800 Subject: [PATCH 1/3] Add in basic asan and tsan support Signed-off-by: Chen Bainian --- industrial_ci/src/docker.env | 2 ++ industrial_ci/src/tests/source_tests.sh | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/industrial_ci/src/docker.env b/industrial_ci/src/docker.env index 021c29e6c..faee58343 100644 --- a/industrial_ci/src/docker.env +++ b/industrial_ci/src/docker.env @@ -34,6 +34,8 @@ ROSDEP_SKIP_KEYS ROSINSTALL_FILENAME ROS_DISTRO ROS_PYTHON_VERSION +RUN_ASAN +RUN_TSAN TARGET_CMAKE_ARGS TARGET_REPO_NAME TARGET_REPO_PATH diff --git a/industrial_ci/src/tests/source_tests.sh b/industrial_ci/src/tests/source_tests.sh index c5b874635..57e1dc10c 100644 --- a/industrial_ci/src/tests/source_tests.sh +++ b/industrial_ci/src/tests/source_tests.sh @@ -125,6 +125,13 @@ function run_source_tests { if [ "${CLANG_TIDY:-false}" != false ]; then TARGET_CMAKE_ARGS="$TARGET_CMAKE_ARGS -DCMAKE_EXPORT_COMPILE_COMMANDS=ON" fi + if [ "$RUN_ASAN" = "true" ]; then + TARGET_CMAKE_ARGS="$TARGET_CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS='-fsanitize=address' -DCMAKE_CXX_FLAGS='-fsanitize=address'" + fi + + if [ "$RUN_TSAN" = "true" ]; then + TARGET_CMAKE_ARGS="$TARGET_CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS='-fsanitize=thread -O2 -g -fno-omit-frame-pointer' -DCMAKE_CXX_FLAGS='-fsanitize=thread -O2 -g -fno-omit-frame-pointer'" + fi ici_with_ws "$target_ws" ici_build_workspace "target" "$extend" "$target_ws" if [ "$NOT_TEST_BUILD" != "true" ]; then From a268889a6807c0b17332992ccf27cc63b5dcfcd6 Mon Sep 17 00:00:00 2001 From: Chen Bainian Date: Thu, 18 Jun 2020 12:29:45 +0800 Subject: [PATCH 2/3] Enable ptrace inside docker for asan Signed-off-by: Chen Bainian --- industrial_ci/src/docker.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/industrial_ci/src/docker.sh b/industrial_ci/src/docker.sh index 1a3378fe8..80b2bf9f8 100644 --- a/industrial_ci/src/docker.sh +++ b/industrial_ci/src/docker.sh @@ -84,6 +84,10 @@ function ici_run_cmd_in_docker() { run_opts+=(-v "$CCACHE_DIR:/root/.ccache" -e "CCACHE_DIR=/root/.ccache") fi + if [ "$RUN_ASAN" = "true" ]; then + run_opts+=(--cap-add SYS_PTRACE) + fi + local hooks=() for hook in $(env | grep -o '^\(BEFORE\|AFTER\)_[^=]*'); do hooks+=(-e "$hook") From 6d43b80ddf83b855975a265096dc78409b75887f Mon Sep 17 00:00:00 2001 From: Chen Bainian Date: Sun, 21 Jun 2020 20:57:27 +0800 Subject: [PATCH 3/3] Disable osrf testing tool memory tool during asan and tsan build Signed-off-by: Chen Bainian --- industrial_ci/src/tests/source_tests.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/industrial_ci/src/tests/source_tests.sh b/industrial_ci/src/tests/source_tests.sh index 57e1dc10c..e3fcfcc9b 100644 --- a/industrial_ci/src/tests/source_tests.sh +++ b/industrial_ci/src/tests/source_tests.sh @@ -126,11 +126,11 @@ function run_source_tests { TARGET_CMAKE_ARGS="$TARGET_CMAKE_ARGS -DCMAKE_EXPORT_COMPILE_COMMANDS=ON" fi if [ "$RUN_ASAN" = "true" ]; then - TARGET_CMAKE_ARGS="$TARGET_CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS='-fsanitize=address' -DCMAKE_CXX_FLAGS='-fsanitize=address'" + TARGET_CMAKE_ARGS="$TARGET_CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug -DOSRF_TESTING_TOOLS_CPP_DISABLE_MEMORY_TOOLS=ON -DCMAKE_C_FLAGS='-fsanitize=address' -DCMAKE_CXX_FLAGS='-fsanitize=address'" fi if [ "$RUN_TSAN" = "true" ]; then - TARGET_CMAKE_ARGS="$TARGET_CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_FLAGS='-fsanitize=thread -O2 -g -fno-omit-frame-pointer' -DCMAKE_CXX_FLAGS='-fsanitize=thread -O2 -g -fno-omit-frame-pointer'" + TARGET_CMAKE_ARGS="$TARGET_CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug -DOSRF_TESTING_TOOLS_CPP_DISABLE_MEMORY_TOOLS=ON -DCMAKE_C_FLAGS='-fsanitize=thread -O2 -g -fno-omit-frame-pointer' -DCMAKE_CXX_FLAGS='-fsanitize=thread -O2 -g -fno-omit-frame-pointer'" fi ici_with_ws "$target_ws" ici_build_workspace "target" "$extend" "$target_ws"