Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Marc Khouzam <marc.khouzam@ericsson.com>
To: "'Joel Brobecker'" <brobecker@adacore.com>,
	       "'Tom Tromey'" <tromey@redhat.com>
Cc: "'gdb-patches@sourceware.org'" <gdb-patches@sourceware.org>
Subject: [Python] Segfault when clearing pspace (was: RE: Assertion failure because of missing inferior)
Date: Wed, 15 Dec 2010 15:57:00 -0000	[thread overview]
Message-ID: <F7CE05678329534C957159168FA70DEC572EA2C1DF@EUSAACMS0703.eamcs.ericsson.se> (raw)
In-Reply-To: <F7CE05678329534C957159168FA70DEC572E9D937F@EUSAACMS0703.eamcs.ericsson.se>


> -----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


  reply	other threads:[~2010-12-15 15:57 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-04 19:11 Assertion failure because of missing inferior Marc Khouzam
2010-12-07 18:54 ` Tom Tromey
2010-12-08  1:38   ` Marc Khouzam
2010-12-10 19:59     ` Tom Tromey
2010-12-10 20:21       ` Marc Khouzam
2010-12-10 21:01         ` Marc Khouzam
2010-12-10 21:38           ` Marc Khouzam
2010-12-14 14:50             ` Tom Tromey
2010-12-14 15:04               ` Joel Brobecker
2010-12-14 15:31                 ` Pedro Alves
2010-12-15  5:12                   ` Joel Brobecker
2010-12-14 20:00                 ` Marc Khouzam
2010-12-15 15:57                   ` Marc Khouzam [this message]
2010-12-16 21:26                     ` [Python] Segfault when clearing pspace Tom Tromey
2010-12-18  2:13                       ` Marc Khouzam
2010-12-18  2:19               ` Assertion failure because of missing inferior Marc Khouzam
2010-12-14 14:49           ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F7CE05678329534C957159168FA70DEC572EA2C1DF@EUSAACMS0703.eamcs.ericsson.se \
    --to=marc.khouzam@ericsson.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tromey@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox