From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id 421683858C50; Tue, 12 Jul 2022 11:58:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 421683858C50 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/testsuite] Run two test-cases with ASAN_OPTIONS=verify_asan_link_order=0 X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 09559238fdcca6ffa2ddfdd6a89ac919a9ccb80d X-Git-Newrev: 75948417af8f86d1b9b0e3b51f904e1345927885 Message-Id: <20220712115834.421683858C50@sourceware.org> Date: Tue, 12 Jul 2022 11:58:34 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jul 2022 11:58:34 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D75948417af8f= 86d1b9b0e3b51f904e1345927885 commit 75948417af8f86d1b9b0e3b51f904e1345927885 Author: Tom de Vries Date: Tue Jul 12 13:58:31 2022 +0200 [gdb/testsuite] Run two test-cases with ASAN_OPTIONS=3Dverify_asan_link= _order=3D0 =20 When building gdb with -fsanitize=3Daddress we run into: ... builtin_spawn gdb -nw -nx -iex set height 0 -iex set width 0 -data-dire= ctory \ build/gdb/data-directory^M =3D=3D10637=3D=3DASan runtime does not come first in initial library li= st; you \ should either link runtime to your application or manually preload it= with \ LD_PRELOAD.^M ERROR: GDB process no longer exists ... =20 Prevent the ASan runtime error by using ASAN_OPTIONS=3Dverify_asan_link_order=3D0. This makes both test-cases = pass. =20 Tested on x86_64-linux. =20 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D29358 Diff: --- gdb/testsuite/gdb.base/libsegfault.exp | 8 +++++++- gdb/testsuite/gdb.threads/attach-slow-waitpid.exp | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/gdb/testsuite/gdb.base/libsegfault.exp b/gdb/testsuite/gdb.bas= e/libsegfault.exp index 6b8453f5550..ceb8c417d4d 100644 --- a/gdb/testsuite/gdb.base/libsegfault.exp +++ b/gdb/testsuite/gdb.base/libsegfault.exp @@ -33,7 +33,7 @@ if { [is_remote host] } { proc gdb_spawn_with_ld_preload {lib cmdline_opts} { global env =20 - save_vars { env(LD_PRELOAD) } { + save_vars { env(LD_PRELOAD) env(ASAN_OPTIONS)} { if { ![info exists env(LD_PRELOAD) ] || $env(LD_PRELOAD) =3D=3D "" } { set env(LD_PRELOAD) "$lib" @@ -41,6 +41,12 @@ proc gdb_spawn_with_ld_preload {lib cmdline_opts} { append env(LD_PRELOAD) ":$lib" } =20 + # Prevent address sanitizer error: + # ASan runtime does not come first in initial library list; you should + # either link runtime to your application or manually preload it with + # LD_PRELOAD. + set_sanitizer_default ASAN_OPTIONS verify_asan_link_order 0 + gdb_spawn_with_cmdline_opts $cmdline_opts } } diff --git a/gdb/testsuite/gdb.threads/attach-slow-waitpid.exp b/gdb/testsu= ite/gdb.threads/attach-slow-waitpid.exp index 68c866a36f0..93b1d88c0dc 100644 --- a/gdb/testsuite/gdb.threads/attach-slow-waitpid.exp +++ b/gdb/testsuite/gdb.threads/attach-slow-waitpid.exp @@ -71,7 +71,7 @@ with_test_prefix "compile test executable" { proc gdb_spawn_with_ld_preload {lib} { global env =20 - save_vars { env(LD_PRELOAD) } { + save_vars { env(LD_PRELOAD) env(ASAN_OPTIONS) } { if { ![info exists env(LD_PRELOAD) ] || $env(LD_PRELOAD) =3D=3D "" } { set env(LD_PRELOAD) "$lib" @@ -79,6 +79,12 @@ proc gdb_spawn_with_ld_preload {lib} { append env(LD_PRELOAD) ":$lib" } =20 + # Prevent address sanitizer error: + # ASan runtime does not come first in initial library list; you should + # either link runtime to your application or manually preload it with + # LD_PRELOAD. + set_sanitizer_default ASAN_OPTIONS verify_asan_link_order 0 + gdb_start } }