Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [patch] Assertion for a regression by gdb_bfd_unref
@ 2009-08-09 21:46 Jan Kratochvil
  2009-08-10  8:51 ` Paul Pluzhnikov
  2009-08-10 20:16 ` Tom Tromey
  0 siblings, 2 replies; 6+ messages in thread
From: Jan Kratochvil @ 2009-08-09 21:46 UTC (permalink / raw)
  To: gdb-patches; +Cc: Paul Pluzhnikov

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-08-10 22:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-09 21:46 [patch] Assertion for a regression by gdb_bfd_unref Jan Kratochvil
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox