This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

[Patch] Fix ICE with java and -freduced-reflection.


When compiling certain java programs (like libgcj) with freduced-reflection, jc1 will ICE with SIGSEGV.

The cause is a small logic error in make_class_data(tree). We allocate a VEC of length zero with VEC_alloc(int, heap, 0) which returns NULL, but then try to add an element with VEC_quick_push() resulting in SIGSEGV as the VEC is NULL. We should only be adding the field indexes if they are static or (uses_jv_markobj || !flag_reduced_reflection), but we unconditionally fall through and always add something.

The fix is to continue the loop if the conditions for field inclusion are not met and not add the bogus index.

Currently bootstrapping/testing on i686-pc-linux-gnu.

OK to commit if it passes?


2008-08-20 David Daney <ddaney@avtrex.com>


	* class.c (make_class_data): Don't add field_index when
	flag_reduced_reflection set.
Index: class.c
===================================================================
--- class.c	(revision 139335)
+++ class.c	(working copy)
@@ -1821,6 +1821,8 @@ make_class_data (tree type)
 	    field_index = static_count++;
 	  else if (uses_jv_markobj || !flag_reduced_reflection)
 	    field_index = instance_count++;
+	  else
+	    continue;
 	  VEC_quick_push (int, field_indexes, field_index);
 	}
     }

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