public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Set PYTHONMALLOC in the test suite
@ 2023-07-28 12:33 Tom Tromey
  2023-07-28 15:37 ` Sam James
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2023-07-28 12:33 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

Setting PYTHONMALLOC helped me locate an earlier bug.  It seems to me
that there aren't big downsides to always setting this during testing,
and it might help find other bugs in the future.
---
 gdb/testsuite/lib/gdb.exp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 66c04a2efe2..12a9c59dece 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -6437,6 +6437,10 @@ proc default_gdb_init { test_file_name } {
     # tests.
     setenv TERM "dumb"
 
+    # This setting helps detect bugs in the Python code and doesn't
+    # seem to have a significant downside for the tests.
+    setenv PYTHONMALLOC malloc_debug
+
     # If DEBUGINFOD_URLS is set, gdb will try to download sources and
     # debug info for f.i. system libraries.  Prevent this.
     if { [is_remote host] } {
-- 
2.40.1


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

* Re: [PATCH] Set PYTHONMALLOC in the test suite
  2023-07-28 12:33 [PATCH] Set PYTHONMALLOC in the test suite Tom Tromey
@ 2023-07-28 15:37 ` Sam James
  2023-07-31 14:21   ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Sam James @ 2023-07-28 15:37 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches


Tom Tromey via Gdb-patches <gdb-patches@sourceware.org> writes:

> Setting PYTHONMALLOC helped me locate an earlier bug.  It seems to me
> that there aren't big downsides to always setting this during testing,
> and it might help find other bugs in the future.

This looks like a good idea. I was a bit disappointed that Python's
Valgrind integration didn't work for you in that bug, because it's
_supposed_ to detect when running under Valgrind and defer to its
malloc instead of its own, but I guess its own debug malloc is
different.

Anyway, yeah, the only downside is speed and that's not
a problem for tests, especially given they're small.

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

* Re: [PATCH] Set PYTHONMALLOC in the test suite
  2023-07-28 15:37 ` Sam James
@ 2023-07-31 14:21   ` Tom Tromey
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2023-07-31 14:21 UTC (permalink / raw)
  To: Sam James; +Cc: Tom Tromey, gdb-patches

>> Setting PYTHONMALLOC helped me locate an earlier bug.  It seems to me
>> that there aren't big downsides to always setting this during testing,
>> and it might help find other bugs in the future.

Sam> This looks like a good idea. I was a bit disappointed that Python's
Sam> Valgrind integration didn't work for you in that bug, because it's
Sam> _supposed_ to detect when running under Valgrind and defer to its
Sam> malloc instead of its own, but I guess its own debug malloc is
Sam> different.

I think the issue here is that the bug is a race, which memcheck
wouldn't find (I didn't try helgrind or whatever).  malloc_debug worked
because it detects GIL violations.

Sam> Anyway, yeah, the only downside is speed and that's not
Sam> a problem for tests, especially given they're small.

I'm going to check this in.  Thanks for your comments.

Tom

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-28 12:33 [PATCH] Set PYTHONMALLOC in the test suite Tom Tromey
2023-07-28 15:37 ` Sam James
2023-07-31 14:21   ` 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).