This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: fix java-related crash


I'm checking this in.

This was reported as:

    https://bugzilla.redhat.com/show_bug.cgi?id=566145

The bug is that we try to gdb_bfd_ref(NULL).  I think this is ok -- we
allow this at unref time.  So, I fixed it by adding a check to
gdb_bfd_ref.

Built and regtested on x86-64 (compile farm).
New test case included.  The new test will only really test anything if
you have the libgcj debuginfo installed.

Tom

2010-02-17  Tom Tromey  <tromey@redhat.com>

	* objfiles.c (gdb_bfd_ref): Handle abfd==NULL.

2010-02-17  Tom Tromey  <tromey@redhat.com>

	* gdb.java/jprint.java (jprint.props): New field.
	* gdb.java/jprint.exp (set_lang_java): Add regression test.

diff --git a/gdb/objfiles.c b/gdb/objfiles.c
index 489b812..c2763c2 100644
--- a/gdb/objfiles.c
+++ b/gdb/objfiles.c
@@ -1504,7 +1504,12 @@ objfiles_changed (void)
 struct bfd *
 gdb_bfd_ref (struct bfd *abfd)
 {
-  int *p_refcount = bfd_usrdata (abfd);
+  int *p_refcount;
+
+  if (abfd == NULL)
+    return NULL;
+
+  p_refcount = bfd_usrdata (abfd);
 
   if (p_refcount != NULL)
     {
diff --git a/gdb/testsuite/gdb.java/jprint.exp b/gdb/testsuite/gdb.java/jprint.exp
index bb929aa..29dbf4b 100644
--- a/gdb/testsuite/gdb.java/jprint.exp
+++ b/gdb/testsuite/gdb.java/jprint.exp
@@ -84,4 +84,7 @@ if ![set_lang_java] then {
     gdb_test "call x.dothat(55)" "new value is 58\r\n.*= 62.*" "virtual fn call"
     gdb_test "p x.addprint(1,2,3)" "sum is 6\r\n.*" "inherited static call"
     gdb_test "call x.addk(44)" "adding k gives 121\r\n.*= 121.*" "inherited virtual fn call"
+
+    # Regression test for a crasher.
+    gdb_test "print *jprint.props" " = .*" "print a java.util.Properties"
 }
diff --git a/gdb/testsuite/gdb.java/jprint.java b/gdb/testsuite/gdb.java/jprint.java
index bd4fa96..01ebdbc 100644
--- a/gdb/testsuite/gdb.java/jprint.java
+++ b/gdb/testsuite/gdb.java/jprint.java
@@ -1,6 +1,6 @@
 // jprint.java test program.
 //
-// Copyright 2004
+// Copyright 2004, 2010
 // Free Software Foundation, Inc.
 //
 // Written by Jeff Johnston <jjohnstn@redhat.com> 
@@ -21,6 +21,8 @@
 // You should have received a copy of the GNU General Public License
 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+import java.util.Properties;
+
 class jvclass {
   public static int k;
   static {
@@ -39,6 +41,8 @@ class jvclass {
 }
     
 public class jprint extends jvclass {
+  public static Properties props = new Properties ();
+
   public int dothat (int x) {
     int y = x + 3;
     System.out.println ("new value is " + y);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]