From bbc133a3083cebcb9d2e010bef47753448d0046f Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Tue, 24 Mar 2026 08:59:31 -0600 Subject: Hold the GIL while clearing gdbpy_reggroup_object_map Tom de Vries pointed out that a certain Python test left a core file. Looking into this, I think the problem is that the GIL is not held when gdbpy_reggroup_object_map is destroyed. This patch changes the code to explicitly clear the global while holding the GIL. This fixed the crash for me. This also adds a comment to gdbpy_initialize_file to explicitly mention that the GIL is held while the finalizers are run. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=34013 Reviewed-By: Tom de Vries --- gdb/python/python-internal.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gdb/python/python-internal.h') diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index bdc960ed208..b24b9314994 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -616,7 +616,9 @@ class gdbpy_initialize_file There is no error return in this case. This function is only called when GDB is already shutting down. The function should make a best - effort to clean up, and then return. */ + effort to clean up, and then return. + + The GIL will be held while calling the finalizers. */ using gdbpy_finalize_file_ftype = void (*) (void); -- cgit v1.2.3