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] Prevent garbage collection during c++ parsing


Hello,

#0  ggc_collect () at ggc-page.c:1788
#1  0x000000000096319c in cgraph_finalize_function (decl=0x2a95d0d270,
    nested=false) at cgraphunit.c:225
#2  0x0000000000548967 in expand_or_defer_fn (fn=0x2a95d0d270)
    at cp/semantics.c:2999
#3  0x00000000004f42e3 in cp_parser_function_definition_after_declarator (
    parser=0x2a958f2b40, inline_p=true) at cp/parser.c:14040
#4  0x00000000004f4f65 in cp_parser_late_parsing_for_member (
    parser=0x2a958f2b40, member_function=0x2a95d0d270) at cp/parser.c:14424
#5  0x00000000004f065d in cp_parser_class_specifier (parser=0x2a958f2b40)
    at cp/parser.c:11692
#6  0x00000000004ec697 in cp_parser_type_specifier (parser=0x2a958f2b40,
    flags=CP_PARSER_FLAGS_OPTIONAL, is_friend=false, is_declaration=true,
    declares_class_or_enum=0x7fbffff174, is_cv_qualifier=0x7fbffff173)
    at cp/parser.c:8559
#7  0x00000000004ea180 in cp_parser_decl_specifier_seq (parser=0x2a958f2b40,
    flags=CP_PARSER_FLAGS_OPTIONAL, attributes=0x7fbffff200,
    declares_class_or_enum=0x7fbffff1fc) at cp/parser.c:6653

this occurs during c++ parsing, which is wrong, since cp_parser_decl_specifier_seq
allocates a tree list, that is freed by the ggc_collect call.

Honza suggested the following hack to prevent cgraph from calling the
garbage collection.  Bootstrapped & regtested on i686.

Zdenek

	* cp/parser.c (cp_parser_class_specifier): Prevent garbage collection.

Index: cp/parser.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.156
diff -c -3 -p -r1.156 parser.c
*** cp/parser.c	15 Jan 2004 14:45:14 -0000	1.156
--- cp/parser.c	15 Jan 2004 21:18:37 -0000
*************** cp_parser_class_specifier (cp_parser* pa
*** 11688,11695 ****
--- 11688,11699 ----
  	  /* Figure out which function we need to process.  */
  	  fn = TREE_VALUE (queue_entry);
  
+ 	  /* A hack to prevent garbage collection.  */
+ 	  function_depth++;
+ 
  	  /* Parse the function.  */
  	  cp_parser_late_parsing_for_member (parser, fn);
+ 	  function_depth--;
  	}
  
      }


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