From: Sergio Durigan Junior <sergiodj@redhat.com>
To: Pedro Alves <palves@redhat.com>
Cc: Tom Tromey <tom@tromey.com>, Tom Tromey <tromey@adacore.com>,
gdb-patches@sourceware.org
Subject: [PATCH] Destroy allocated values when exiting GDB (was: Re: [PATCH] Merge handle_inferior_event and handle_inferior_event_1)
Date: Fri, 29 Mar 2019 21:44:00 -0000 [thread overview]
Message-ID: <87lg0xwe3t.fsf_-_@redhat.com> (raw)
In-Reply-To: <5a2d4016-9e4d-dc18-8c3a-2c9ecf214c94@redhat.com> (Pedro Alves's message of "Thu, 28 Mar 2019 14:12:42 +0000")
On Thursday, March 28 2019, Pedro Alves wrote:
> On 03/27/2019 12:57 PM, Tom Tromey wrote:
>> Sergio> I did that, and we (Pedro, Mark, Frank and I) did a session of
>> Sergio> collective investigation. I summarized what we found here:
>> Sergio> https://bugzilla.redhat.com/show_bug.cgi?id=1690120#c25
>>
>> Thanks, that's very interesting.
>> I suppose either better control over the order of destruction is needed,
>> or maybe finalize_python should clear gdb_python_initialized and then
>> this should be checked in xmethod destructor.
> I think the former is better. I think we should put an
> all_values.clear ();
> call in quit_force, before the do_final_cleanups call. Even
> better, add a new finalize_values function next to
> _initialize_values, and call that.
How does this look?
From b88067edfb2289cd5af3c9b8984b0b0354c965db Mon Sep 17 00:00:00 2001
From: Sergio Durigan Junior <sergiodj@redhat.com>
Date: Fri, 29 Mar 2019 17:34:54 -0400
Subject: [PATCH] Destroy allocated values when exiting GDB
When the user exits GDB, we might still have some allocated values in
the chain, which, in specific scenarios, can cause problems when GDB
attempts to destroy them in "quit_force". For example, see the bug
reported at:
https://bugzilla.redhat.com/show_bug.cgi?id=1690120
And the thread starting at:
https://sourceware.org/ml/gdb-patches/2019-03/msg00475.html
Message-ID: <87r2azkhmq.fsf@redhat.com>
In order to avoid that, and to be more aware of our allocated
resources, this commit implements a new function "finalize_values" and
calls it from inside "quit_force".
Tested by the BuildBot.
2019-03-29 Sergio Durigan Junior <sergiodj@redhat.com>
Pedro Alves <palves@redhat.com>
* top.c (quit_force): Call 'finalize_values'.
* value.c (finalize_values): New function.
* value.h (finalize_values): Declare.
---
gdb/top.c | 3 +++
gdb/value.c | 8 ++++++++
gdb/value.h | 4 ++++
3 files changed, 15 insertions(+)
diff --git a/gdb/top.c b/gdb/top.c
index b10b0649e9..ffbe8e517f 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1672,6 +1672,9 @@ quit_force (int *exit_arg, int from_tty)
}
END_CATCH
+ /* Destroy any values currently allocated. */
+ finalize_values ();
+
/* Do any final cleanups before exiting. */
TRY
{
diff --git a/gdb/value.c b/gdb/value.c
index dc297dfe0f..bcfc084e09 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -4132,3 +4132,11 @@ prevents future values, larger than this size, from being allocated."),
selftests::test_insert_into_bit_range_vector);
#endif
}
+
+/* See value.h. */
+
+void
+finalize_values ()
+{
+ all_values.clear ();
+}
diff --git a/gdb/value.h b/gdb/value.h
index d3905cc354..7853950ca3 100644
--- a/gdb/value.h
+++ b/gdb/value.h
@@ -1189,4 +1189,8 @@ extern struct value *call_xmethod (struct value *method,
extern int value_union_variant (struct type *union_type,
const gdb_byte *contents);
+/* Destroy the values currently allocated. This is mostly called when
+ GDB is exiting (e.g., on quit_force). */
+extern void finalize_values ();
+
#endif /* !defined (VALUE_H) */
--
2.17.2
next prev parent reply other threads:[~2019-03-29 21:44 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20190320140846.13031-1-tromey@adacore.com>
2019-03-20 16:21 ` [PATCH] Merge handle_inferior_event and handle_inferior_event_1 Pedro Alves
2019-03-21 22:05 ` Sergio Durigan Junior
2019-03-22 0:01 ` Sergio Durigan Junior
2019-03-25 15:35 ` Tom Tromey
2019-03-25 16:34 ` Pedro Alves
2019-03-25 16:46 ` Tom Tromey
2019-03-25 22:20 ` Sergio Durigan Junior
2019-03-26 13:13 ` Tom Tromey
2019-03-26 16:07 ` Sergio Durigan Junior
2019-03-26 18:45 ` Tom Tromey
2019-03-26 21:50 ` Sergio Durigan Junior
2019-03-27 12:57 ` Tom Tromey
2019-03-28 14:12 ` Pedro Alves
2019-03-29 21:44 ` Sergio Durigan Junior [this message]
2019-04-01 14:08 ` [PATCH] Destroy allocated values when exiting GDB Pedro Alves
2019-04-01 14:59 ` Sergio Durigan Junior
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=87lg0xwe3t.fsf_-_@redhat.com \
--to=sergiodj@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.com \
--cc=tom@tromey.com \
--cc=tromey@adacore.com \
/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