public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] [gdb/testsuite] Set TSAN_OPTIONS by default to history_size=7
@ 2023-07-31  7:15 Tom de Vries
  2023-07-31 16:37 ` Tom Tromey
  0 siblings, 1 reply; 2+ messages in thread
From: Tom de Vries @ 2023-07-31  7:15 UTC (permalink / raw)
  To: gdb-patches

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


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

* Re: [PATCH] [gdb/testsuite] Set TSAN_OPTIONS by default to history_size=7
  2023-07-31  7:15 [PATCH] [gdb/testsuite] Set TSAN_OPTIONS by default to history_size=7 Tom de Vries
@ 2023-07-31 16:37 ` Tom Tromey
  0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2023-07-31 16:37 UTC (permalink / raw)
  To: Tom de Vries via Gdb-patches; +Cc: Tom de Vries

>>>>> "Tom" == Tom de Vries via Gdb-patches <gdb-patches@sourceware.org> writes:

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

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

Tom> Tested on x86_64-linux.

Seems totally fine for me.  Thank you for this & for trying out
ThreadSanitizer.

Approved-By: Tom Tromey <tom@tromey.com>

Tom

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

end of thread, other threads:[~2023-07-31 16:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-31  7:15 [PATCH] [gdb/testsuite] Set TSAN_OPTIONS by default to history_size=7 Tom de Vries
2023-07-31 16:37 ` Tom Tromey

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).