[4/5] Add final cleanup for runnables
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Testing passed
|
Commit Message
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(+)
@@ -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 ();
+ });
}