This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix gdb.multi/base.exp, gdb memory corruption
- From: Doug Evans <dje at google dot com>
- To: Yao Qi <yao at codesourcery dot com>, <gdb-patches at sourceware dot org>
- Date: Tue, 20 May 2014 13:33:12 -0700
- Subject: Re: [PATCH] Fix gdb.multi/base.exp, gdb memory corruption
- Authentication-results: sourceware.org; auth=none
- References: <yjt2wqdhwli8 dot fsf at ruffy dot mtv dot corp dot google dot com> <537AEA79 dot 2090602 at codesourcery dot com>
Here is what I checked in.
2014-05-20 Doug Evans <dje@google.com>
* python/py-progspace.c (py_free_pspace): Call target_gdbarch
instead of get_current_arch.
diff --git a/gdb/python/py-progspace.c b/gdb/python/py-progspace.c
index cda5a86..db4c564 100644
--- a/gdb/python/py-progspace.c
+++ b/gdb/python/py-progspace.c
@@ -241,7 +241,16 @@ py_free_pspace (struct program_space *pspace, void *datum)
{
struct cleanup *cleanup;
pspace_object *object = datum;
- struct gdbarch *arch = get_current_arch ();
+ /* This is a fiction, but we're in a nasty spot: The pspace is in the
+ process of being deleted, we can't rely on anything in it. Plus
+ this is one time when the current program space and current inferior
+ are not in sync: All inferiors that use PSPACE may no longer exist.
+ We don't need to do much here, and since "there is always an inferior"
+ using target_gdbarch suffices.
+ Note: We cannot call get_current_arch because it may try to access
+ the target, which may involve accessing data in the pspace currently
+ being deleted. */
+ struct gdbarch *arch = target_gdbarch ();
cleanup = ensure_python_env (arch, current_language);
object->pspace = NULL;