public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/testsuite: set ASAN_OPTIONS=detect_leaks=0 while running tests
@ 2021-11-02 20:34 Simon Marchi
  2021-11-03 10:24 ` Tom de Vries
  0 siblings, 1 reply; 11+ messages in thread
From: Simon Marchi @ 2021-11-02 20:34 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

We see some additional failures when running the testsuite against a GDB
compiled with ASan, compared to a GDB compiled without ASan.  Some of
them are caused by the memory leak report shown by the GDB process when
it exits, and the fact that it makes it exit with a non-zero exit code.

I generally try to remember to set ASAN_OPTIONS=detect_leaks=0 in my
environment when running the tests, but I don't always do it.  I think
it would be nice if the testsuite did it.  I don't see any use to have
leak detection when running the tests.  That is, unless we ever have a
test that ensures GDB doesn't leak memory, which isn't going to happen
any time soon.

Here are some tests I found that were affected by this:

    gdb.base/batch-exit-status.exp
    gdb.base/many-headers.exp: read core file
    gdb.base/quit.exp
    gdb.base/with-mf.exp
    gdb.dwarf2/gdb-add-index.exp
    gdb.dwarf2/gdb-add-index-symlink.exp
    gdb.dwarf2/imported-unit-runto-main.exp

Change-Id: I784c7df8a13979eb96587f735c1d33ba2cc6e0ca
---
 gdb/testsuite/lib/gdb.exp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 7f02504262d..97bedd5cb58 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -25,6 +25,13 @@ if {$tool == ""} {
     exit 2
 }
 
+# If GDB is built with ASAN (and because there are leaks), it will output a
+# leak report when exiting as well as exit with a non-zero (failure) status.
+# This can affect tests that are sensitive to what GDB prints on stderr or its
+# exit status.  Add `detect_leaks=0` to the ASAN_OPTIONS environment variable
+# (which will affect any spawned sub-process) to avoid this.
+append ::env(ASAN_OPTIONS) ",detect_leaks=0"
+
 # List of procs to run in gdb_finish.
 set gdb_finish_hooks [list]
 
-- 
2.33.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-11-10 13:32 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-02 20:34 [PATCH] gdb/testsuite: set ASAN_OPTIONS=detect_leaks=0 while running tests Simon Marchi
2021-11-03 10:24 ` Tom de Vries
2021-11-03 12:28   ` Tom de Vries
2021-11-03 14:45     ` Simon Marchi
2021-11-04 11:55       ` Tom de Vries
2021-11-04 20:04   ` Simon Marchi
2021-11-05 10:03     ` [gdb/build] Fix Wimplicit-exception-spec-mismatch in clang build Tom de Vries
2021-11-05 14:24       ` Simon Marchi
2021-11-05 17:00         ` Pedro Alves
2021-11-05 17:07       ` Pedro Alves
2021-11-10 13:32         ` 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).