This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Python] Segfault when clearing pspace (was: RE: Assertion failure because of missing inferior)


> -----Original Message-----
> From: gdb-patches-owner@sourceware.org 
> [mailto:gdb-patches-owner@sourceware.org] On Behalf Of Marc Khouzam
> Sent: Tuesday, December 14, 2010 3:00 PM
> To: 'Joel Brobecker'; 'Tom Tromey'
> Cc: 'gdb-patches@sourceware.org'
> Subject: RE: Assertion failure because of missing inferior
> 
> > -----Original Message-----
> > From: gdb-patches-owner@sourceware.org 
> > [mailto:gdb-patches-owner@sourceware.org] On Behalf Of Joel 
> Brobecker
> > Sent: Tuesday, December 14, 2010 10:05 AM
> > To: Tom Tromey
> > Cc: Marc Khouzam; gdb-patches@sourceware.org
> > Subject: Re: Assertion failure because of missing inferior
> > 
> > > Marc> 2010-12-10  Marc Khouzam  <marc.khouzam@ericsson.com>
> > > Marc>    * mi/mi-main.c (mi_cmd_remove_inferior): Don't 
> > delete current inferior.
> > > Marc>    (get_other_inferior): New.
> > > 
> > > I think this is ok for the 7.2 branch, assuming Joel didn't do the
> > > release already :)
> > 
> > I'll wait for the go ahead from you guys - I get confused with the
> > various emails...
> 
> So, although I feel that this patch is good, it seems to be
> only a first step in getting 'remove-inferior' to work.  Once
> I have this patch applied, I'm getting further but hitting
> another crash.  I'm still working on a patch for that.  I don't
> think the current patch is going to help 7.2.1 unless the other
> crash is also fixed, so I'll wait before committing it.

I tracked down the crash when removing an inferior to the python
cleanup method: py_free_pspace().  This method tries to obtain
the gdbarch from pspace->symfile_object_file, but that pointer
has already been cleaned.  The patch below uses gdb_current_arch()
instead and that fixes the crash.  I don't know
if I'm allowed to use this method in this context and if it
returns the same arch as what was part of the pspace that is
being cleaned.

The existing FIXME comment about how to get the arch seems to 
confirm that something should be fixed there.

Below the patch is a session that shows how to reproduce
the crash.

What do you think?

Marc


### Eclipse Workspace Patch 1.0
#P src
Index: gdb/python/py-progspace.c
===================================================================
RCS file: /cvs/src/src/gdb/python/py-progspace.c,v
retrieving revision 1.3
diff -u -r1.3 py-progspace.c
--- gdb/python/py-progspace.c   17 May 2010 21:23:25 -0000      1.3
+++ gdb/python/py-progspace.c   15 Dec 2010 15:00:01 -0000
@@ -23,6 +23,7 @@
 #include "progspace.h"
 #include "objfiles.h"
 #include "language.h"
+#include "arch-utils.h"
 
 typedef struct
 {
@@ -136,7 +137,7 @@
   pspace_object *object = datum;
   /* FIXME: What's the right way to get a program space's arch?
      There may be multiple.  */
-  struct gdbarch *arch = get_objfile_arch (pspace->symfile_object_file);
+  struct gdbarch *arch = get_current_arch ();
 
   cleanup = ensure_python_env (arch, current_language);
   object->pspace = NULL;



===================


> gdb.7.2
GNU gdb (GDB) 7.2
(gdb) file  /home/lmckhou/runtime-TestDSF/DSFTestApp/Debug/DSFTestApp
Reading symbols from /home/lmckhou/runtime-TestDSF/DSFTestApp/Debug/DSFTestApp...done.
(gdb) start
Temporary breakpoint 1 at 0x80489f4: file ../src/DSFTestApp.cpp, line 1155.
Starting program: /home/lmckhou/runtime-TestDSF/DSFTestApp/Debug/DSFTestApp 
[Thread debugging using libthread_db enabled]

Temporary breakpoint 1, main (argc=1, argv=0xbffff7e4) at ../src/DSFTestApp.cpp:1155
1155        int de = 99;
(gdb) add-inferior 
Added inferior 2
(gdb) inferior 2
[Switching to inferior 2 [process 0] (<noexec>)]
(gdb) file /home/lmckhou/testing/a.out
Reading symbols from /home/lmckhou/testing/a.out...done.
(gdb) start
Temporary breakpoint 2 at 0x80484a9: file a.cc, line 9.
Starting program: /home/lmckhou/testing/a.out 

Temporary breakpoint 2, main () at a.cc:9
9           f();
(gdb) inf inf
  Num  Description       Executable        
* 2    process 8158      /home/lmckhou/testing/a.out 
  1    process 8154      /home/lmckhou/runtime-TestDSF/DSFTestApp/Debug/DSFTestApp 
(gdb) detach inferior 1
(gdb) inf inf
  Num  Description       Executable        
  2    process 8158      /home/lmckhou/testing/a.out 
* 1    <null>            /home/lmckhou/runtime-TestDSF/DSFTestApp/Debug/DSFTestApp 
(gdb) inferior 2
[Switching to inferior 2 [process 8158] (/home/lmckhou/testing/a.out)]
[Switching to thread 2 (process 8158)] 
#0  main () at a.cc:9
9           f();
(gdb) inf inf
  Num  Description       Executable        
* 2    process 8158      /home/lmckhou/testing/a.out 
  1    <null>            /home/lmckhou/runtime-TestDSF/DSFTestApp/Debug/DSFTestApp 
(gdb) remove-inferior 1
(gdb) inf inf
  Num  Description       Executable        
* 2    process 8158      /home/lmckhou/testing/a.out 
(gdb) n
10          return 1;
Segmentation fault


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]