unroller bug

Jeffrey A Law law@cygnus.com
Mon Nov 1 22:40:00 GMT 1999


This latent bug starting showing up on the PA recently.

Basically it is possible for map->reg_map to never be initialized in
unroll_loop depending the precise path through that function.

This leads to a crash & burn when we free (map->reg_map).

	* unroll.c (unroll_loop): Allocate memory for MAP using xcalloc.
	Remove explicit zero initializations of entries within MAP.

Index: unroll.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/unroll.c,v
retrieving revision 1.75
diff -c -3 -p -r1.75 unroll.c
*** unroll.c	1999/11/01 23:19:44	1.75
--- unroll.c	1999/11/02 06:37:19
*************** unroll_loop (loop_end, insn_count, loop_
*** 682,691 ****
    max_labelno = max_label_num ();
    max_insnno = get_max_uid ();
  
!   map = (struct inline_remap *) xmalloc (sizeof (struct inline_remap));
  
!   map->integrating = 0;
!   map->const_equiv_varray = 0;
  
    /* Allocate the label map.  */
  
--- 682,692 ----
    max_labelno = max_label_num ();
    max_insnno = get_max_uid ();
  
!   /* Various paths through the unroll code may reach the "egress" label
!      without initializing fields within the map structure.
  
!      To be safe, we use xcalloc to zero the memory.  */
!   map = (struct inline_remap *) xcalloc (1, sizeof (struct inline_remap));
  
    /* Allocate the label map.  */
  
*************** unroll_loop (loop_end, insn_count, loop_
*** 695,702 ****
  
        local_label = (char *) xcalloc (max_labelno, sizeof (char));
      }
-   else
-     map->label_map = 0;
  
    /* Search the loop and mark all local labels, i.e. the ones which have to
       be distinct labels when copied.  For all labels which might be
--- 696,701 ----





More information about the Gcc-patches mailing list