From e6b5bcc69e3fcbbf1d2a6b760cc68827ccb50cc4 Mon Sep 17 00:00:00 2001 From: JiaShuo Date: Tue, 17 Dec 2019 17:34:25 +0800 Subject: [PATCH 1/6] add sanitizer --- run.sh | 18 +++++++++++++++++- src/build.sh | 8 ++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/run.sh b/run.sh index e7f462b408..f5fe9eb9c8 100755 --- a/run.sh +++ b/run.sh @@ -71,10 +71,15 @@ function usage_build() echo " -v|--verbose build in verbose mode, default no" echo " --disable_gperf build without gperftools, this flag is mainly used" echo " to enable valgrind memcheck, default no" + echo " --sanitizer build with sanitizer to check potential problem: + address, leak, thread, undefined etc." echo " --skip_thirdparty whether to skip building thirdparties, default no" } function run_build() { + #Note: No memory mode, because MemorySanitizer is only available in Clang for Linux x86_64 targets + SANITIZERS=("address" "leak" "thread" "undefined") + C_COMPILER="gcc" CXX_COMPILER="g++" BUILD_TYPE="release" @@ -88,6 +93,7 @@ function run_build() RUN_VERBOSE=NO DISABLE_GPERF=NO SKIP_THIRDPARTY=NO + SANITIZER="" TEST_MODULE="" while [[ $# > 0 ]]; do key="$1" @@ -134,6 +140,16 @@ function run_build() --enable_gcov) ENABLE_GCOV=YES ;; + --sanitizer) + IS_SANITIZERS=`echo ${SANITIZERS[@]} | grep -w $2` + if [[ -z ${IS_SANITIZERS} ]]; then + echo "ERROR: unknown sanitizer type \"$2\"" + usage_build + exit 1 + fi + SANITIZER="$2" + shift + ;; -v|--verbose) RUN_VERBOSE=YES ;; @@ -283,7 +299,7 @@ function run_build() cd $ROOT/src C_COMPILER="$C_COMPILER" CXX_COMPILER="$CXX_COMPILER" BUILD_TYPE="$BUILD_TYPE" \ CLEAR="$CLEAR" PART_CLEAR="$PART_CLEAR" JOB_NUM="$JOB_NUM" \ - BOOST_DIR="$BOOST_DIR" WARNING_ALL="$WARNING_ALL" ENABLE_GCOV="$ENABLE_GCOV" \ + BOOST_DIR="$BOOST_DIR" WARNING_ALL="$WARNING_ALL" ENABLE_GCOV="$ENABLE_GCOV" SANITIZER="$SANITIZER"\ RUN_VERBOSE="$RUN_VERBOSE" TEST_MODULE="$TEST_MODULE" DISABLE_GPERF="$DISABLE_GPERF" ./build.sh if [ $? -ne 0 ]; then echo "ERROR: build pegasus failed" diff --git a/src/build.sh b/src/build.sh index e86ff040e0..a3ae448424 100755 --- a/src/build.sh +++ b/src/build.sh @@ -79,6 +79,14 @@ else echo "ENABLE_GCOV=NO" fi +if [ ! -z "$SANITIZER" ] +then + echo "Build with sanitizer: sanitizer=$SANITIZER" + CMAKE_OPTIONS="$CMAKE_OPTIONS -DSANITIZER=$SANITIZER" +else + echo "Build without sanitizer" +fi + # valgrind can not work together with gpertools # you may want to use this option when you want to run valgrind if [ "$DISABLE_GPERF" == "YES" ] From bdd43d464a6d98f545e68c403c5241d15130e45e Mon Sep 17 00:00:00 2001 From: JiaShuo Date: Tue, 17 Dec 2019 17:50:29 +0800 Subject: [PATCH 2/6] add sanitizer --- run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/run.sh b/run.sh index f5fe9eb9c8..563ebe9200 100755 --- a/run.sh +++ b/run.sh @@ -71,8 +71,8 @@ function usage_build() echo " -v|--verbose build in verbose mode, default no" echo " --disable_gperf build without gperftools, this flag is mainly used" echo " to enable valgrind memcheck, default no" - echo " --sanitizer build with sanitizer to check potential problem: - address, leak, thread, undefined etc." + echo " --sanitizer build with sanitizer to check potential problem, + type: address|leak|thread|undefined" echo " --skip_thirdparty whether to skip building thirdparties, default no" } function run_build() From 7f34ade4d91ff9890a6cccfc7c57131d12c785e8 Mon Sep 17 00:00:00 2001 From: JiaShuo Date: Tue, 17 Dec 2019 17:51:49 +0800 Subject: [PATCH 3/6] add sanitizer --- run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run.sh b/run.sh index 563ebe9200..e9420046d4 100755 --- a/run.sh +++ b/run.sh @@ -77,7 +77,7 @@ function usage_build() } function run_build() { - #Note: No memory mode, because MemorySanitizer is only available in Clang for Linux x86_64 targets + #Note: No memory check mode, because MemorySanitizer is only available in Clang for Linux x86_64 targets SANITIZERS=("address" "leak" "thread" "undefined") C_COMPILER="gcc" From 4dfd4e63ed31021ef7b670255e004c8e1b6a3748 Mon Sep 17 00:00:00 2001 From: JiaShuo Date: Thu, 19 Dec 2019 13:37:02 +0800 Subject: [PATCH 4/6] add sanitizer --- run.sh | 4 ++-- src/build.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/run.sh b/run.sh index e9420046d4..9bd37ffaaa 100755 --- a/run.sh +++ b/run.sh @@ -71,13 +71,13 @@ function usage_build() echo " -v|--verbose build in verbose mode, default no" echo " --disable_gperf build without gperftools, this flag is mainly used" echo " to enable valgrind memcheck, default no" - echo " --sanitizer build with sanitizer to check potential problem, + echo " --sanitizer build with sanitizer to check potential problems, type: address|leak|thread|undefined" echo " --skip_thirdparty whether to skip building thirdparties, default no" } function run_build() { - #Note: No memory check mode, because MemorySanitizer is only available in Clang for Linux x86_64 targets + # Note(jiashuo1): No "memory" check mode, because MemorySanitizer is only available in Clang for Linux x86_64 targets SANITIZERS=("address" "leak" "thread" "undefined") C_COMPILER="gcc" diff --git a/src/build.sh b/src/build.sh index a3ae448424..f7b3dbdafe 100755 --- a/src/build.sh +++ b/src/build.sh @@ -81,7 +81,7 @@ fi if [ ! -z "$SANITIZER" ] then - echo "Build with sanitizer: sanitizer=$SANITIZER" + echo "SANITIZER=$SANITIZER" CMAKE_OPTIONS="$CMAKE_OPTIONS -DSANITIZER=$SANITIZER" else echo "Build without sanitizer" From 2a59fd636f84ffa9113423aa01264ad0289d2c73 Mon Sep 17 00:00:00 2001 From: JiaShuo Date: Thu, 19 Dec 2019 13:39:14 +0800 Subject: [PATCH 5/6] add sanitizer --- run.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/run.sh b/run.sh index 9bd37ffaaa..d23b865b63 100755 --- a/run.sh +++ b/run.sh @@ -78,6 +78,7 @@ function usage_build() function run_build() { # Note(jiashuo1): No "memory" check mode, because MemorySanitizer is only available in Clang for Linux x86_64 targets + # # https://www.jetbrains.com/help/clion/google-sanitizers.html SANITIZERS=("address" "leak" "thread" "undefined") C_COMPILER="gcc" From 2b0c6b925f7c4e975f0ac89add7c283860251419 Mon Sep 17 00:00:00 2001 From: JiaShuo Date: Thu, 19 Dec 2019 15:34:15 +0800 Subject: [PATCH 6/6] add sanitizer --- run.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/run.sh b/run.sh index d23b865b63..45a386839f 100755 --- a/run.sh +++ b/run.sh @@ -217,6 +217,9 @@ function run_build() if [ "$SKIP_THIRDPARTY" == "YES" ]; then OPT="$OPT --skip_thirdparty" fi + if [ ! -z $SANITIZER ]; then + OPT="$OPT --sanitizer $SANITIZER" + fi ./run.sh build $OPT --notest if [ $? -ne 0 ]; then echo "ERROR: build rdsn failed"