From: Andreas Schneider Date: Tue, 6 Sep 2022 06:59:56 +0000 (+0200) Subject: selftest: Fix address sanitizer with python3 X-Git-Tag: talloc-2.4.0~1112 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1591d7bdbf045bee45e7e2775a7be464fe236d1c;p=thirdparty%2Fsamba.git selftest: Fix address sanitizer with python3 ==9542==AddressSanitizer: failed to intercept 'crypt' ==9542==AddressSanitizer: failed to intercept 'crypt_r' [..] AddressSanitizer:DEADLYSIGNAL ================================================================= ==29768==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x000000000000 bp 0x7ffcec4bf3c0 sp 0x7ffcec4beb58 T0) ==29768==Hint: pc points to the zero page. ==29768==The signal is caused by a READ memory access. ==29768==Hint: address points to the zero page. #0 0x0 () #1 0x7f052cca4129 in crypt_crypt_impl /usr/src/debug/python310-core-3.10.6-3.1.x86_64/Modules/_cryptmodule.c:44 We would need to build python without --as-needed as we can't so that we need to preload the library to avoid a segfault. See also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98669 Signed-off-by: Andreas Schneider Reviewed-by: Douglas Bagnall Reviewed-by: Andrew Bartlett --- diff --git a/selftest/selftest.pl b/selftest/selftest.pl index 3332de632ad..11f8e92e84e 100755 --- a/selftest/selftest.pl +++ b/selftest/selftest.pl @@ -62,6 +62,7 @@ my $opt_libresolv_wrapper_so_path = ""; my $opt_libsocket_wrapper_so_path = ""; my $opt_libuid_wrapper_so_path = ""; my $opt_libasan_so_path = ""; +my $opt_libcrypt_so_path = ""; my $opt_use_dns_faking = 0; my @testlists = (); @@ -248,6 +249,7 @@ my $result = GetOptions ( 'socket_wrapper_so_path=s' => \$opt_libsocket_wrapper_so_path, 'uid_wrapper_so_path=s' => \$opt_libuid_wrapper_so_path, 'asan_so_path=s' => \$opt_libasan_so_path, + 'crypt_so_path=s' => \$opt_libcrypt_so_path, 'use-dns-faking' => \$opt_use_dns_faking ); @@ -346,9 +348,17 @@ my $ld_preload = $ENV{LD_PRELOAD}; if ($opt_libasan_so_path) { if ($ld_preload) { - $ld_preload = "$opt_libasan_so_path:$ld_preload"; + if ($opt_libcrypt_so_path) { + $ld_preload = "$opt_libasan_so_path:$opt_libcrypt_so_path:$ld_preload"; + } else { + $ld_preload = "$opt_libasan_so_path:$ld_preload"; + } } else { - $ld_preload = "$opt_libasan_so_path"; + if ($opt_libcrypt_so_path) { + $ld_preload = "$opt_libasan_so_path:$opt_libcrypt_so_path"; + } else { + $ld_preload = "$opt_libasan_so_path"; + } } } diff --git a/selftest/wscript b/selftest/wscript index a8b6d45cd1d..03637c52165 100644 --- a/selftest/wscript +++ b/selftest/wscript @@ -291,6 +291,14 @@ def cmd_testonly(opt): # Have the selftest.pl LD_PRELOAD libasan in the right spot env.OPTIONS += " --asan_so_path=" + libasan + if CONFIG_SET(opt, 'HAVE_CRYPT_R'): + # We try to find the correct libcrypt automatically + libcrypt = Utils.cmd_output( + 'ldd bin/modules/ldb/password_hash.so | awk \'/libcrypt.so/ { print $3 }\'', + silent=True).strip() + libcrypt = libcrypt.decode('utf8') + env.OPTIONS += " --crypt_so_path=" + libcrypt + subunit_cache = None # We use the full path rather than relative path to avoid problems on some platforms (ie. solaris 8). env.CORE_COMMAND = '${PERL} ${srcdir}/selftest/selftest.pl --target=${SELFTEST_TARGET} --prefix=${SELFTEST_PREFIX} --srcdir=${srcdir} --exclude=${srcdir}/selftest/skip ${TESTLISTS} ${OPTIONS} ${TESTS}'