Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Kratochvil <jan.kratochvil@redhat.com>
To: gdb-patches@sourceware.org
Cc: Paul Pluzhnikov <ppluzhnikov@google.com>
Subject: [patch] Assertion for a regression by gdb_bfd_unref
Date: Sun, 09 Aug 2009 21:46:00 -0000	[thread overview]
Message-ID: <20090809213710.GA14354@host0.dyn.jankratochvil.net> (raw)

Hi,

since
	Re: Solibs and objfile BFD ownership ownership
	http://sourceware.org/ml/gdb/2009-08/msg00020.html
	http://sourceware.org/ml/gdb-cvs/2009-08/msg00013.html

there is a regression:

CFLAGS=-g ./configure --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu --target=powerpc64-unknown-linux-gnu --enable-targets=i386-unknown-go32
make
echo 'main(){}' >1.c;gcc -o 1 1.c -g;./gdb/gdb -nx -ex 'set confirm no' -ex 'file ./1' -ex 'b main' -ex file
GNU gdb (GDB) 6.8.50.20090809-cvs
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "--host=x86_64-unknown-linux-gnu --target=powerpc64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Breakpoint 1 at 0x400480: file 1.c, line 1.
Don't know how to run.  Try "help target".
objfiles.c:1029: internal-error: gdb_bfd_unref: Assertion `p_refcount == NULL || *p_refcount == 1 || *p_refcount == 2' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Aborted

With the attached patch the reason is:

symfile.c:1642: internal-error: symfile_bfd_open: Assertion `bfd_usrdata (sym_bfd) == NULL' failed.

(found it while using --enable-targets=all)

Going to post now patches to binutils for bfd/ to fix the bfd_usrdata
initialization.


Thanks,
Jan


gdb/
2009-08-09  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* objfiles.c (gdb_bfd_unref): Use the bfd_usrdata accessor.
	* solib.c (symbol_add_stub): Likewise.
	* symfile.c (symfile_bfd_open): Assert BFD_USRDATA is NULL.

--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -1022,7 +1022,7 @@ gdb_bfd_unref (struct bfd *abfd)
   if (abfd == NULL)
     return;
 
-  p_refcount = abfd->usrdata;
+  p_refcount = bfd_usrdata (abfd);
 
   /* Valid range for p_refcount: NULL (single owner), or a pointer
      to int counter, which has a value of 1 (single owner) or 2 (shared).  */
@@ -1035,7 +1035,7 @@ gdb_bfd_unref (struct bfd *abfd)
 	return;
     }
   xfree (p_refcount);
-  abfd->usrdata = NULL;  /* Paranoia.  */
+  bfd_usrdata (abfd) = NULL;  /* Paranoia.  */
 
   name = bfd_get_filename (abfd);
   if (!bfd_close (abfd))
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -459,7 +459,7 @@ symbol_add_stub (struct so_list *so, int flags)
   so->objfile = symbol_file_add_from_bfd (so->abfd, flags, sap, OBJF_SHARED);
   p_refcount = xmalloc (sizeof (*p_refcount));
   *p_refcount = 2;  /* Both solib and objfile refer to this abfd.  */
-  so->abfd->usrdata = p_refcount;
+  bfd_usrdata (so->abfd) = p_refcount;
 
   free_section_addr_info (sap);
 
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1638,6 +1638,9 @@ symfile_bfd_open (char *name)
 	     bfd_errmsg (bfd_get_error ()));
     }
 
+  /* bfd_usrdata exists for applications and libbfd must not touch it.
+  gdb_assert (bfd_usrdata (sym_bfd) == NULL);
+
   return sym_bfd;
 }
 


             reply	other threads:[~2009-08-09 21:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-09 21:46 Jan Kratochvil [this message]
2009-08-10  8:51 ` Paul Pluzhnikov
2009-08-10 20:16 ` Tom Tromey
2009-08-10 22:23   ` Jan Kratochvil
2009-08-10 22:26     ` Paul Pluzhnikov
2009-08-10 23:49       ` Jan Kratochvil

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=20090809213710.GA14354@host0.dyn.jankratochvil.net \
    --to=jan.kratochvil@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=ppluzhnikov@google.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