From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30207 invoked by alias); 15 Dec 2010 15:57:29 -0000 Received: (qmail 30193 invoked by uid 22791); 15 Dec 2010 15:57:28 -0000 X-SWARE-Spam-Status: No, hits=-1.5 required=5.0 tests=AWL,BAYES_00,TW_BJ X-Spam-Check-By: sourceware.org Received: from imr4.ericy.com (HELO imr4.ericy.com) (198.24.6.8) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 15 Dec 2010 15:57:23 +0000 Received: from eusaamw0706.eamcs.ericsson.se ([147.117.20.31]) by imr4.ericy.com (8.14.3/8.14.3/Debian-9.1ubuntu1) with ESMTP id oBFGS8Rm004826; Wed, 15 Dec 2010 10:28:16 -0600 Received: from EUSAACMS0703.eamcs.ericsson.se ([169.254.1.63]) by eusaamw0706.eamcs.ericsson.se ([147.117.20.31]) with mapi; Wed, 15 Dec 2010 10:56:49 -0500 From: Marc Khouzam To: "'Joel Brobecker'" , "'Tom Tromey'" CC: "'gdb-patches@sourceware.org'" Date: Wed, 15 Dec 2010 15:57:00 -0000 Subject: [Python] Segfault when clearing pspace (was: RE: Assertion failure because of missing inferior) Message-ID: References: <20101214150430.GV2596@adacore.com> In-Reply-To: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2010-12/txt/msg00302.txt.bz2 > -----Original Message----- > From: gdb-patches-owner@sourceware.org=20 > [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 >=20 > > -----Original Message----- > > From: gdb-patches-owner@sourceware.org=20 > > [mailto:gdb-patches-owner@sourceware.org] On Behalf Of Joel=20 > 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 > >=20 > > > Marc> 2010-12-10 Marc Khouzam > > > Marc> * mi/mi-main.c (mi_cmd_remove_inferior): Don't=20 > > delete current inferior. > > > Marc> (get_other_inferior): New. > > >=20 > > > I think this is ok for the 7.2 branch, assuming Joel didn't do the > > > release already :) > >=20 > > I'll wait for the go ahead from you guys - I get confused with the > > various emails... >=20 > 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=20 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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" =20 typedef struct { @@ -136,7 +137,7 @@ pspace_object *object =3D datum; /* FIXME: What's the right way to get a program space's arch? There may be multiple. */ - struct gdbarch *arch =3D get_objfile_arch (pspace->symfile_object_file); + struct gdbarch *arch =3D get_current_arch (); =20 cleanup =3D ensure_python_env (arch, current_language); object->pspace =3D NULL; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > 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/DSFTest= App...done. (gdb) start Temporary breakpoint 1 at 0x80489f4: file ../src/DSFTestApp.cpp, line 1155. Starting program: /home/lmckhou/runtime-TestDSF/DSFTestApp/Debug/DSFTestApp= =20 [Thread debugging using libthread_db enabled] Temporary breakpoint 1, main (argc=3D1, argv=3D0xbffff7e4) at ../src/DSFTes= tApp.cpp:1155 1155 int de =3D 99; (gdb) add-inferior=20 Added inferior 2 (gdb) inferior 2 [Switching to inferior 2 [process 0] ()] (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=20 Temporary breakpoint 2, main () at a.cc:9 9 f(); (gdb) inf inf Num Description Executable=20=20=20=20=20=20=20=20 * 2 process 8158 /home/lmckhou/testing/a.out=20 1 process 8154 /home/lmckhou/runtime-TestDSF/DSFTestApp/Debug/DSF= TestApp=20 (gdb) detach inferior 1 (gdb) inf inf Num Description Executable=20=20=20=20=20=20=20=20 2 process 8158 /home/lmckhou/testing/a.out=20 * 1 /home/lmckhou/runtime-TestDSF/DSFTestApp/Debug/DSF= TestApp=20 (gdb) inferior 2 [Switching to inferior 2 [process 8158] (/home/lmckhou/testing/a.out)] [Switching to thread 2 (process 8158)]=20 #0 main () at a.cc:9 9 f(); (gdb) inf inf Num Description Executable=20=20=20=20=20=20=20=20 * 2 process 8158 /home/lmckhou/testing/a.out=20 1 /home/lmckhou/runtime-TestDSF/DSFTestApp/Debug/DSF= TestApp=20 (gdb) remove-inferior 1 (gdb) inf inf Num Description Executable=20=20=20=20=20=20=20=20 * 2 process 8158 /home/lmckhou/testing/a.out=20 (gdb) n 10 return 1; Segmentation fault