From b81b4d62d53fd74f3849bbb621f2f06324ae90ab Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Wed, 9 Oct 2024 16:26:25 +0100 Subject: [PATCH] testsuite: fix gcc/libasan.so load order Currently we silence the ordering warning from libasan, via the environment: ASAN_OPTIONS=verify_asan_link_order=0... Instead we should be LD_PRELOAD-ing the library, since otherwise we might end with miss-matched symbols - one coming from libasan, with the counter part from the system library. Plus LD_PRELOAD is the only way to make the clang sanitizers work... That I have found. Although that's coming with a later patch. v2: - handle when the file is a script Signed-off-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/179 Signed-off-by: Lucas De Marchi --- scripts/test-wrapper.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/test-wrapper.sh b/scripts/test-wrapper.sh index 78b48324..073446f1 100755 --- a/scripts/test-wrapper.sh +++ b/scripts/test-wrapper.sh @@ -3,8 +3,14 @@ set -euo pipefail if [[ ${ASAN_OPTIONS-} || ${UBSAN_OPTIONS-} || ${MSAN_OPTIONS-} ]]; then - ASAN_OPTIONS=verify_asan_link_order=0:halt_on_error=1:abort_on_error=1:print_summary=1 - export ASAN_OPTIONS + LD_PRELOAD=$(gcc -print-file-name=libasan.so) + # In some cases, like in Fedora, the file is a script which cannot be + # preloaded. Attempt to extract the details from within. + if grep -q INPUT "$LD_PRELOAD"; then + input=$(sed -r -n "s/INPUT \( (.*) \)/\1/p" "$LD_PRELOAD") + test -f "$input" && LD_PRELOAD="$input" + fi + export LD_PRELOAD fi exec "$@" -- 2.47.2