diff options
author | Tom Tromey <tromey@adacore.com> | 2024-02-23 13:26:02 -0700 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2024-02-27 10:30:29 -0700 |
commit | 6313c05640cf6e2f6b1b1b8e66789b34b45f19c7 (patch) | |
tree | 55693788a67d3334ab0c033590407225b7962b3e /gdb | |
parent | ec471b627aa76fa8ac1f103ecabd73e304e952c8 (diff) | |
download | gdb-6313c05640cf6e2f6b1b1b8e66789b34b45f19c7.zip gdb-6313c05640cf6e2f6b1b1b8e66789b34b45f19c7.tar.gz gdb-6313c05640cf6e2f6b1b1b8e66789b34b45f19c7.tar.bz2 |
Add final cleanup for runnables
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
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/run-on-main-thread.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gdb/run-on-main-thread.c b/gdb/run-on-main-thread.c index 2d40048..7b9807e 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 (); + }); } |