public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "vries at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug python/31172] gdb.post_event SIGSEGV in batch mode
Date: Mon, 29 Jan 2024 10:45:09 +0000 [thread overview]
Message-ID: <bug-31172-4717-uC2RzPG39v@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-31172-4717@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=31172
Tom de Vries <vries at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |vries at gcc dot gnu.org
--- Comment #1 from Tom de Vries <vries at gcc dot gnu.org> ---
Tentative fix, similar to what is done for finalize_values:
...
diff --git a/gdb/run-on-main-thread.c b/gdb/run-on-main-thread.c
index 2d40048de56..e06b751f221 100644
--- a/gdb/run-on-main-thread.c
+++ b/gdb/run-on-main-thread.c
@@ -33,6 +33,14 @@ static struct serial_event *runnable_event;
static std::vector<std::function<void ()>> runnables;
+/* See run-on-main-thread.h. */
+
+void
+finalize_runnables (void)
+{
+ runnables.clear ();
+}
+
#if CXX_STD_THREAD
/* Mutex to hold when handling RUNNABLE_EVENT or RUNNABLES. */
diff --git a/gdb/run-on-main-thread.h b/gdb/run-on-main-thread.h
index 4f370dddb9e..27eaff3df72 100644
--- a/gdb/run-on-main-thread.h
+++ b/gdb/run-on-main-thread.h
@@ -29,4 +29,8 @@ extern void run_on_main_thread (std::function<void ()> &&);
extern bool is_main_thread ();
+/* Destroy the runnables currently allocated. This is called when GDB is
+ exiting (e.g., on quit_force). */
+extern void finalize_runnables ();
+
#endif /* GDB_RUN_ON_MAIN_THREAD_H */
diff --git a/gdb/top.c b/gdb/top.c
index fb15c719564..221ef329951 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -74,6 +74,7 @@
#include "cli-out.h"
#include "tracepoint.h"
#include "inf-loop.h"
+#include "run-on-main-thread.h"
#if defined(TUI)
# include "tui/tui.h"
@@ -1813,6 +1814,10 @@ quit_force (int *exit_arg, int from_tty)
runtime, which is finalized via a final cleanup. */
finalize_values ();
+ /* Likewise, destroy any runnables currenctly allocated now. The destructor
+ of gdbpy_event calls into the Python runtime. */
+ finalize_runnables ();
+
/* Do any final cleanups before exiting. */
try
{
...
With this patch, we have:
...
$ gdb --batch -ex 'pi gdb.post_event(lambda : print("test"))'
$
...
--
You are receiving this mail because:
You are on the CC list for the bug.
next prev parent reply other threads:[~2024-01-29 10:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-16 0:44 [Bug python/31172] New: " mitch at runsafesecurity dot com
2024-01-29 10:45 ` vries at gcc dot gnu.org [this message]
2024-01-29 11:28 ` [Bug python/31172] " vries at gcc dot gnu.org
2024-02-23 20:26 ` tromey at sourceware dot org
2024-02-23 20:27 ` tromey at sourceware dot org
2024-02-27 17:38 ` cvs-commit at gcc dot gnu.org
2024-02-27 17:38 ` tromey at sourceware dot org
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=bug-31172-4717-uC2RzPG39v@http.sourceware.org/bugzilla/ \
--to=sourceware-bugzilla@sourceware.org \
--cc=gdb-prs@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).