This is the mail archive of the gcc@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]

bootstrap failure, gcc HEAD, Boolean.java


I have a bootstrap failure with gcc HEAD on native i686-pc-linux-gnu.
It looks like a memory management thinko in a recent Java patch.

My host is native i686-pc-linux-gnu, red hat 8.0, using gcc 3.3.2,
binutils 2.14, and gnu make 3.79.1 to do the bootstrap.  I configure
with "--disable-shared" and I build with "make all".

The failing command and its error messages are:

  /berman/fsf/shelf/2004-01-09-17-10-00/berman/build/target/native/gcc/gcc-HEAD-as-2.14-ld-2.14/gcc/gcj -B/berman/fsf/shelf/2004-01-09-17-10-00/berman/build/target/native/gcc/gcc-HEAD-as-2.14-ld-2.14/i686-pc-linux-gnu/libjava/ -B/berman/fsf/shelf/2004-01-09-17-10-00/berman/build/target/native/gcc/gcc-HEAD-as-2.14-ld-2.14/gcc/ --encoding=UTF-8 -Wno-deprecated -fclasspath= -fbootclasspath=/berman/fsf/shelf/2004-01-09-17-10-00/berman/build/target/native/gcc/gcc-HEAD-as-2.14-ld-2.14/i686-pc-linux-gnu/libjava -ffloat-store -g -O2 -MD -MT java/lang/Boolean.lo -MF java/lang/Boolean.d -c /berman/fsf/shelf/2004-01-09-17-10-00/source/gcc/HEAD/gcc/libjava/java/lang/Boolean.java -o java/lang/Boolean.o
  /tmp/cch40gGW.s: Assembler messages:
  /tmp/cch40gGW.s:882: Error: unrecognized symbol type ""
  /tmp/cch40gGW.s:882: Warning: rest of line ignored; first ignored character is `:'
  /tmp/cch40gGW.s:883: Error: expected comma after name `ê' in .size directive
  /tmp/cch40gGW.s:883: Warning: rest of line ignored; first ignored character is `:'
  /tmp/cch40gGW.s:884: Error: invalid character (0x8) in mnemonic
  /tmp/cch40gGW.s:926: Warning: rest of line ignored; first ignored character is `:'
  make[2]: *** [java/lang/Boolean.lo] Error 1
  make[2]: Leaving directory `/berman/fsf/shelf/2004-01-09-17-10-00/berman/build/target/native/gcc/gcc-HEAD-as-2.14-ld-2.14/i686-pc-linux-gnu/libjava'
  make[1]: *** [all-recursive] Error 1
  make[1]: Leaving directory `/berman/fsf/shelf/2004-01-09-17-10-00/berman/build/target/native/gcc/gcc-HEAD-as-2.14-ld-2.14/i686-pc-linux-gnu/libjava'
  make: *** [all-target-libjava] Error 2

I narrowed the problem down to this patch:

  2004-01-09  Andrew Haley  <aph@redhat.com>

          PR java/12755:
          * parse.y (java_fix_constructors):  Set output_class.
          (java_reorder_fields): Likewise.
          (java_layout_classes): Likewise.
          (java_expand_classes): Generate indirect dispatch tables.
          (java_expand_classes): Set output_class.
          (java_finish_classes): Likewise.
          ...

The old code does this:

     ctable_decl
       = build_decl (VAR_DECL, get_identifier ("catch_classes"),
                    build_array_type
                    (catch_class_type, 0));

The new code does this:

   {
     tree field = NULL;
     char *buf = alloca (strlen (typename) + strlen ("_catch_classes_"));
     tree catch_class_type = make_node (RECORD_TYPE);
 
     sprintf (buf, "_catch_classes_%s", typename);
     PUSH_FIELD (catch_class_type, field, "address", utf8const_ptr_type);
     PUSH_FIELD (catch_class_type, field, "classname", ptr_type_node);
     FINISH_RECORD (catch_class_type);
 
     TYPE_CTABLE_DECL (type)
       = build_decl (VAR_DECL, get_identifier (buf),
                    build_array_type (catch_class_type, 0));
     ...
   }

Aha, the call to "alloca" is not long enough for the NUL at the end of
the string!  This also happens with _otable_syms_ and _atable_syms_.

I fixed the calls to alloca in the obvious way.

Here is a patch.  Of course, if you want to fix it some other way,
that's fine with me.  I have a copyright assignment for gcc.

I tested this by running 'make all' on native i686-pc-linux-gnu, and
then I compiled Boolean.java to assembly and checked the assembly code
versus the last good version and and the first bad version.

I'm a little surprised that I am the first person to be bit by this.
It's no big deal, though.

Michael C

===

2004-01-15  Michael Chastain  <mec.gnu@mindspring.com>

	* class.c (gen_indirect_dispatch_tables): Fix string length
	calculations.

Index: class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/class.c,v
retrieving revision 1.175
diff -c -3 -p -r1.175 class.c
*** class.c	9 Jan 2004 17:08:43 -0000	1.175
--- class.c	15 Jan 2004 05:46:04 -0000
*************** gen_indirect_dispatch_tables (tree type)
*** 313,319 ****
    const char *typename = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
    {  
      tree field = NULL;
!     char *buf = alloca (strlen (typename) + strlen ("_catch_classes_"));
      tree catch_class_type = make_node (RECORD_TYPE);
  
      sprintf (buf, "_catch_classes_%s", typename);
--- 313,319 ----
    const char *typename = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
    {  
      tree field = NULL;
!     char *buf = alloca (strlen (typename) + strlen ("_catch_classes_") + 1);
      tree catch_class_type = make_node (RECORD_TYPE);
  
      sprintf (buf, "_catch_classes_%s", typename);
*************** gen_indirect_dispatch_tables (tree type)
*** 335,341 ****
    if (flag_indirect_dispatch)
      {
        {
! 	char *buf = alloca (strlen (typename) + strlen ("_otable_syms_"));
  
  	sprintf (buf, "_otable_%s", typename);
  	TYPE_OTABLE_DECL (type) = 
--- 335,341 ----
    if (flag_indirect_dispatch)
      {
        {
! 	char *buf = alloca (strlen (typename) + strlen ("_otable_syms_") + 1);
  
  	sprintf (buf, "_otable_%s", typename);
  	TYPE_OTABLE_DECL (type) = 
*************** gen_indirect_dispatch_tables (tree type)
*** 356,362 ****
        }
  
        {
! 	char *buf = alloca (strlen (typename) + strlen ("_atable_syms_"));
  	tree decl;
  
  	sprintf (buf, "_atable_%s", typename);
--- 356,362 ----
        }
  
        {
! 	char *buf = alloca (strlen (typename) + strlen ("_atable_syms_") + 1);
  	tree decl;
  
  	sprintf (buf, "_atable_%s", typename);


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