From 2fe4230dfbbb5f7a147cfd537d2ec93785e06c0e Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Mon, 16 Aug 2021 16:24:05 -0700 Subject: [PATCH 1/5] Add flag to source sanitizer suppressions (cherry picked from commit b91aa134ce3451351a80d4bd7100480473c1be14) --- testing/run_tests.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/testing/run_tests.py b/testing/run_tests.py index eed3bcb1faeb1..9c0d2799dd09f 100755 --- a/testing/run_tests.py +++ b/testing/run_tests.py @@ -545,8 +545,8 @@ def main(): help='Generate coverage reports for each unit test framework run.') parser.add_argument('--engine-capture-core-dump', dest='engine_capture_core_dump', action='store_true', default=False, help='Capture core dumps from crashes of engine tests.') - parser.add_argument('--asan-options', dest='asan_options', action='store', type=str, default='', - help='Runtime AddressSanitizer flags to use if built wth asan (example: "verbosity=1:detect_leaks=0') + parser.add_argument('--use-sanitizer-suppressions', dest='sanitizer_suppressions', action='store_true', + default=False, help='Provide the sanitizer suppressions lists to the via environment to the tests.') args = parser.parse_args() @@ -559,8 +559,17 @@ def main(): if args.type != 'java': assert os.path.exists(build_dir), 'Build variant directory %s does not exist!' % build_dir - if args.asan_options: - os.environ['ASAN_OPTIONS'] = args.asan_options + if args.sanitizer_suppressions: + file_dir = os.path.dirname(os.path.abspath(__file__)) + command = [ + "env", "-i", "bash", + "-c", f"source {file_dir}/sanitizer_suppressions.sh >/dev/null && env" + ] + process = subprocess.Popen(command, stdout=subprocess.PIPE) + for line in process.stdout: + key, _, value = str(line).partition("=") + os.environ[key] = value + process.communicate() # Avoid pipe deadlock while waiting for termination. engine_filter = args.engine_filter.split(',') if args.engine_filter else None if 'engine' in types: From 33d1b10e3ebddf65e198f82a52c323a9ec009cdd Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Mon, 16 Aug 2021 16:31:38 -0700 Subject: [PATCH 2/5] Suppress leaks (cherry picked from commit 472280db0f2cba99e02fcc1133fcf103eddbbbb0) --- testing/sanitizer_suppressions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/sanitizer_suppressions.sh b/testing/sanitizer_suppressions.sh index 6a170c40faa53..2ffe3318cf904 100755 --- a/testing/sanitizer_suppressions.sh +++ b/testing/sanitizer_suppressions.sh @@ -13,4 +13,4 @@ export UBSAN_OPTIONS="suppressions=${UBSAN_SUPPRESSIONS_FILE}" echo "Using Undefined Behavior suppressions in ${UBSAN_SUPPRESSIONS_FILE}" -export ASAN_OPTIONS="detect_leaks=1" +export ASAN_OPTIONS="detect_leaks=0" From 71a51d2093e4c0d3fb213a833b72df6b67bea3ea Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Mon, 16 Aug 2021 18:38:40 -0700 Subject: [PATCH 3/5] py2 fix in run_tests.py (cherry picked from commit ce6d0488e7d3ae56e7ffab6664c1159fe07e3928) --- testing/run_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/run_tests.py b/testing/run_tests.py index 9c0d2799dd09f..f5f5e3ffd43d9 100755 --- a/testing/run_tests.py +++ b/testing/run_tests.py @@ -563,7 +563,7 @@ def main(): file_dir = os.path.dirname(os.path.abspath(__file__)) command = [ "env", "-i", "bash", - "-c", f"source {file_dir}/sanitizer_suppressions.sh >/dev/null && env" + "-c", "source {}/sanitizer_suppressions.sh >/dev/null && env".format(file_dir) ] process = subprocess.Popen(command, stdout=subprocess.PIPE) for line in process.stdout: From c631c3c4b506dad7eaec89873d483574cdf5fbc3 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Tue, 17 Aug 2021 10:31:54 -0700 Subject: [PATCH 4/5] Correct testing directory location for runtime sanitizer scripts (cherry picked from commit f5e611ae7641e9cf75838af99d42ab56547f0bea) --- testing/sanitizer_suppressions.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/testing/sanitizer_suppressions.sh b/testing/sanitizer_suppressions.sh index 2ffe3318cf904..d0ecc1244dad1 100755 --- a/testing/sanitizer_suppressions.sh +++ b/testing/sanitizer_suppressions.sh @@ -1,14 +1,14 @@ -CURRENT_DIRECTORY="$(pwd)/$(dirname "$0")" +TESTING_DIRECTORY=$(dirname "${BASH_SOURCE[0]}") -TSAN_SUPPRESSIONS_FILE="${CURRENT_DIRECTORY}/tsan_suppressions.txt" +TSAN_SUPPRESSIONS_FILE="${TESTING_DIRECTORY}/tsan_suppressions.txt" export TSAN_OPTIONS="suppressions=${TSAN_SUPPRESSIONS_FILE}" echo "Using Thread Sanitizer suppressions in ${TSAN_SUPPRESSIONS_FILE}" -LSAN_SUPPRESSIONS_FILE="${CURRENT_DIRECTORY}/lsan_suppressions.txt" +LSAN_SUPPRESSIONS_FILE="${TESTING_DIRECTORY}/lsan_suppressions.txt" export LSAN_OPTIONS="suppressions=${LSAN_SUPPRESSIONS_FILE}" echo "Using Leak Sanitizer suppressions in ${LSAN_SUPPRESSIONS_FILE}" -UBSAN_SUPPRESSIONS_FILE="${CURRENT_DIRECTORY}/ubsan_suppressions.txt" +UBSAN_SUPPRESSIONS_FILE="${TESTING_DIRECTORY}/ubsan_suppressions.txt" export UBSAN_OPTIONS="suppressions=${UBSAN_SUPPRESSIONS_FILE}" echo "Using Undefined Behavior suppressions in ${UBSAN_SUPPRESSIONS_FILE}" From 3152de81002a996abbf9d08ea4207bcf46575ec9 Mon Sep 17 00:00:00 2001 From: Brandon DeRosier Date: Tue, 17 Aug 2021 12:22:55 -0700 Subject: [PATCH 5/5] Suppress container_overflow (cherry picked from commit 221d6e85abbcbe0a3ae93a83cb6799c2ffb3a27f) --- testing/sanitizer_suppressions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/sanitizer_suppressions.sh b/testing/sanitizer_suppressions.sh index d0ecc1244dad1..a6ce6802fa34f 100755 --- a/testing/sanitizer_suppressions.sh +++ b/testing/sanitizer_suppressions.sh @@ -13,4 +13,4 @@ export UBSAN_OPTIONS="suppressions=${UBSAN_SUPPRESSIONS_FILE}" echo "Using Undefined Behavior suppressions in ${UBSAN_SUPPRESSIONS_FILE}" -export ASAN_OPTIONS="detect_leaks=0" +export ASAN_OPTIONS="detect_leaks=0:detect_container_overflow=0"