public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
From: Mathieu Lacage <mathieu.lacage@gmail.com>
To: tromey@redhat.com
Cc: gdb@sourceware.org
Subject: Re: gdb crash: double free with free_objfile
Date: Wed, 23 Jun 2010 15:15:00 -0000	[thread overview]
Message-ID: <AANLkTimzl4KmA-bnXnLTnANEjmPG2CE7t06ggyi3ReV_@mail.gmail.com> (raw)
In-Reply-To: <m3bpg3het5.fsf@fleche.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 892 bytes --]

hi,

On Fri, Feb 5, 2010 at 5:39 PM, Tom Tromey <tromey@redhat.com> wrote:

> Nope, right now objfile has the base address baked in to many things,
> e.g. symbol addresses or psymtabs_addrmap.  I think we'd like to change
> this, so that we can share objfiles between inferiors, but nobody has
> tried to do that yet.  I don't know how hard this would be.
>
> Your quickest route is probably a form of (a) -- change symbol_add_stub
> to check both the file name and the base address.

It took me a long time to get back to this issue because I was busy
with a couple of other things but the attached patch which was
generated against CVS HEAD fixes the problem for me (i.e., avoids the
segfault in gdb and gets me readable backtraces). Is there something
else I could do to help get this issue fixed in mainline ?

Mathieu
-- 
Mathieu Lacage <mathieu.lacage@gmail.com>

[-- Attachment #2: solib.patch --]
[-- Type: application/octet-stream, Size: 1335 bytes --]

? objdir
? solib.patch
Index: gdb/objfiles.h
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.h,v
retrieving revision 1.72
diff -u -r1.72 objfiles.h
--- gdb/objfiles.h	14 Apr 2010 17:26:11 -0000	1.72
+++ gdb/objfiles.h	23 Jun 2010 15:14:16 -0000
@@ -193,6 +193,8 @@
 
     char *name;
 
+    CORE_ADDR addr_low;
+
     /* Some flag bits for this objfile. */
 
     unsigned short flags;
Index: gdb/solib.c
===================================================================
RCS file: /cvs/src/src/gdb/solib.c,v
retrieving revision 1.140
diff -u -r1.140 solib.c
--- gdb/solib.c	16 May 2010 23:49:58 -0000	1.140
+++ gdb/solib.c	23 Jun 2010 15:14:16 -0000
@@ -634,11 +634,11 @@
       TRY_CATCH (e, RETURN_MASK_ERROR)
 	{
 	  struct section_addr_info *sap;
-
 	  /* Have we already loaded this shared object?  */
 	  ALL_OBJFILES (so->objfile)
 	    {
-	      if (strcmp (so->objfile->name, so->so_name) == 0)
+	      if (strcmp (so->objfile->name, so->so_name) == 0
+		  && so->objfile->addr_low == so->addr_low)
 		break;
 	    }
 	  if (so->objfile != NULL)
@@ -648,6 +648,7 @@
 							    so->sections_end);
 	  so->objfile = symbol_file_add_from_bfd (so->abfd,
 						  flags, sap, OBJF_SHARED);
+	  so->objfile->addr_low = so->addr_low;
 	  free_section_addr_info (sap);
 	}
 

  reply	other threads:[~2010-06-23 15:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-05 12:23 Mathieu Lacage
2010-02-05 15:40 ` Tom Tromey
2010-06-23 15:15   ` Mathieu Lacage [this message]
2010-06-29 11:57     ` Mathieu Lacage

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=AANLkTimzl4KmA-bnXnLTnANEjmPG2CE7t06ggyi3ReV_@mail.gmail.com \
    --to=mathieu.lacage@gmail.com \
    --cc=gdb@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).