Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/5] Add final cleanup for runnables
Date: Fri, 23 Feb 2024 14:11:40 -0700	[thread overview]
Message-ID: <20240223-final-cleanups-v1-4-84d5271e9979@adacore.com> (raw)
In-Reply-To: <20240223-final-cleanups-v1-0-84d5271e9979@adacore.com>

This changes run-on-main-thread.c to clear 'runnables' in a final
cleanup.  This avoids an issue where a pending runnable could require
Python, but be run after the Python interpreter was finalized.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31172
---
 gdb/run-on-main-thread.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/gdb/run-on-main-thread.c b/gdb/run-on-main-thread.c
index 2d40048de56..7b9807e0eaf 100644
--- a/gdb/run-on-main-thread.c
+++ b/gdb/run-on-main-thread.c
@@ -133,4 +133,15 @@ _initialize_run_on_main_thread ()
   runnable_event = make_serial_event ();
   add_file_handler (serial_event_fd (runnable_event), run_events, nullptr,
 		    "run-on-main-thread");
+
+  /* A runnable may refer to an extension language.  So, we want to
+     make sure any pending ones have been deleted before the extension
+     languages are shut down.  */
+  add_final_cleanup ([] ()
+    {
+#if CXX_STD_THREAD
+      std::lock_guard lock (runnable_mutex);
+#endif
+      runnables.clear ();
+    });
 }

-- 
2.43.0


  parent reply	other threads:[~2024-02-23 21:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-23 21:11 [PATCH 0/5] Restore DAP 'quit' request Tom Tromey
2024-02-23 21:11 ` [PATCH 1/5] Rewrite final cleanups Tom Tromey
2024-02-25 22:30   ` Lancelot SIX
2024-02-26 18:53     ` Tom Tromey
2024-02-27 14:03       ` Lancelot SIX
2024-02-27 17:27         ` Tom Tromey
2024-02-27 17:36           ` Tom Tromey
2024-03-03 16:50           ` Lancelot SIX
2024-02-23 21:11 ` [PATCH 2/5] Add extension_language_ops::shutdown Tom Tromey
2024-02-23 21:11 ` [PATCH 3/5] Change finalize_values into a final cleanup Tom Tromey
2024-02-23 21:11 ` Tom Tromey [this message]
2024-02-23 21:11 ` [PATCH 5/5] Explicitly quit gdb from DAP server thread 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=20240223-final-cleanups-v1-4-84d5271e9979@adacore.com \
    --to=tromey@adacore.com \
    --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