public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [PATCH] [gdb/testsuite] Set TSAN_OPTIONS by default to history_size=7
Date: Mon, 31 Jul 2023 09:15:47 +0200	[thread overview]
Message-ID: <20230731071547.1140-1-tdevries@suse.de> (raw)

I build gdb with -fsanitize=thread and ran the testsuite, and into the case
that a race is detected, but we see the full stack trace only for one of the
two accesses, and the other one is showing "failed to restore the stack".

Try to prevent this by setting ThreadSanitizer flag history_size [1] to the
maximum (7) by default, as suggested here [2].

Tested on x86_64-linux.

[1] https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags
[2] https://groups.google.com/g/thread-sanitizer/c/VzSWE7UxhIE
---
 gdb/testsuite/lib/gdb.exp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 66c04a2efe2..c42f5308752 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -71,6 +71,14 @@ proc set_sanitizer_default { env_var var_id val } {
 set_sanitizer_default TSAN_OPTIONS suppressions \
     $srcdir/../tsan-suppressions.txt
 
+# When using ThreadSanitizer we may run into the case that a race is detected,
+# but we see the full stack trace only for one of the two accesses, and the
+# other one is showing "failed to restore the stack".
+# Try to prevent this by setting history_size to the maximum (7) by default.
+# See also the ThreadSanitizer docs (
+# https://github.com/google/sanitizers/wiki/ThreadSanitizerFlags ).
+set_sanitizer_default TSAN_OPTIONS history_size 7
+
 # 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

base-commit: 8e72ee1de8df0789c0ac593467d34387af388c83
-- 
2.35.3


             reply	other threads:[~2023-07-31  7:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-31  7:15 Tom de Vries [this message]
2023-07-31 16:37 ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230731071547.1140-1-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).