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

[ada] fix garbage collection problem

Compiling g-spipat.adb segfaulted at -O2 on alpha-linux.  The
problem is that between

2303         gnu_loop_var = gnat_to_gnu_entity (gnat_loop_var, gnu_first, 1);


2379         gnu_expr = build_binary_op (gnu_update, TREE_TYPE (gnu_loop_var),
2380                                     gnu_loop_var,
2381                                     convert (TREE_TYPE (gnu_loop_var),
2382                                              integer_one_node));

gnu_loop_var was garbage collected.  I'm not sure if this
value was supposed to also be on some global datastructure
that is marked, however, I notice that Ada does not care
for GC around nested functions like the other front ends do.

The following fixes the problem for me.



	* utils.c (end_subprog_body): Push GC context around
	rest_of_compilation for nested functions.

Index: utils.c
RCS file: /cvs/gcc/gcc/gcc/ada/utils.c,v
retrieving revision 1.7
diff -c -p -d -r1.7 utils.c
*** utils.c	2001/12/16 01:13:56	1.7
--- utils.c	2001/12/23 21:23:41
*************** end_subprog_body ()
*** 1844,1850 ****
--- 1844,1860 ----
    DECL_CONTEXT (DECL_RESULT (current_function_decl)) = current_function_decl;
    expand_function_end (input_filename, lineno, 0);
+   /* If this is a nested function, push a new GC context.  That will keep
+      local variables on the stack from being collected while we're doing
+      the compilation of this function.  */
+   if (function_nesting_depth > 0)
+     ggc_push_context ();
    rest_of_compilation (current_function_decl);
+   if (function_nesting_depth > 0)
+     ggc_pop_context ();
  #if 0
    /* If we're sure this function is defined in this file then mark it

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