public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] [gdb/testsuite] Run two test-cases with ASAN_OPTIONS=verify_asan_link_order=0
@ 2022-07-12 11:58 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2022-07-12 11:58 UTC (permalink / raw)
  To: gdb-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=75948417af8f86d1b9b0e3b51f904e1345927885

commit 75948417af8f86d1b9b0e3b51f904e1345927885
Author: Tom de Vries <tdevries@suse.de>
Date:   Tue Jul 12 13:58:31 2022 +0200

    [gdb/testsuite] Run two test-cases with ASAN_OPTIONS=verify_asan_link_order=0
    
    When building gdb with -fsanitize=address we run into:
    ...
    builtin_spawn gdb -nw -nx -iex set height 0 -iex set width 0 -data-directory \
      build/gdb/data-directory^M
    ==10637==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.^M
    ERROR: GDB process no longer exists
    ...
    
    Prevent the ASan runtime error by using
    ASAN_OPTIONS=verify_asan_link_order=0.  This makes both test-cases pass.
    
    Tested on x86_64-linux.
    
    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29358

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.base/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
 
-    save_vars { env(LD_PRELOAD) } {
+    save_vars { env(LD_PRELOAD) env(ASAN_OPTIONS)} {
 	if { ![info exists env(LD_PRELOAD) ]
 	     || $env(LD_PRELOAD) == "" } {
 	    set env(LD_PRELOAD) "$lib"
@@ -41,6 +41,12 @@ proc gdb_spawn_with_ld_preload {lib cmdline_opts} {
 	    append env(LD_PRELOAD) ":$lib"
 	}
 
+	# 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/testsuite/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
 
-    save_vars { env(LD_PRELOAD) } {
+    save_vars { env(LD_PRELOAD) env(ASAN_OPTIONS) } {
 	if { ![info exists env(LD_PRELOAD) ]
 	     || $env(LD_PRELOAD) == "" } {
 	    set env(LD_PRELOAD) "$lib"
@@ -79,6 +79,12 @@ proc gdb_spawn_with_ld_preload {lib} {
 	    append env(LD_PRELOAD) ":$lib"
 	}
 
+	# 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
     }
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-12 11:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-12 11:58 [binutils-gdb] [gdb/testsuite] Run two test-cases with ASAN_OPTIONS=verify_asan_link_order=0 Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).