This is the mail archive of the
mailing list for the GCC project.
Re: [C++ PATCH] Avoid GC during cp_parser_parenthesized_expression_list (PR c++/88180)
- From: Jason Merrill <jason at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 18 Dec 2018 17:29:41 -0500
- Subject: Re: [C++ PATCH] Avoid GC during cp_parser_parenthesized_expression_list (PR c++/88180)
- References: <20181218204930.GT23305@tucnak>
On 12/18/18 3:49 PM, Jakub Jelinek wrote:
cp_parser_parenthesized_expression_list creates expression_list in GC
memory; if it is called when current_function_decl is NULL, there might be
ggc_collect in the middle of the parsing and collect that vector.
Fixed by temporarily bumping function_depth. Or should that be done in some
other function from this function down to the ggc_collect (the PR has full
backtrace when that happens)?
#2 0x0000000000c56d6a in ggc_collect () at ../../gcc/ggc-page.c:2207
#3 0x0000000000d30095 in cgraph_node::finalize_function (decl=<function_decl 0x7fffefdda200 c>, no_collect=false) at ../../gcc/cgraphunit.c:492
#4 0x0000000000b18c8c in expand_or_defer_fn (fn=<function_decl 0x7fffefdda200 c>) at ../../gcc/cp/semantics.c:4300
#5 0x0000000000a34edf in cp_parser_function_definition_after_declarator (parser=0x7ffff7ff6ab0, inline_p=true) at ../../gcc/cp/parser.c:27338
#6 0x0000000000a375f6 in cp_parser_late_parsing_for_member (parser=0x7ffff7ff6ab0, member_function=<function_decl 0x7fffefdda200 c>)
#7 0x0000000000a2d75f in cp_parser_class_specifier_1 (parser=0x7ffff7ff6ab0) at ../../gcc/cp/parser.c:23240
#8 0x0000000000a2d83c in cp_parser_class_specifier (parser=0x7ffff7ff6ab0) at ../../gcc/cp/parser.c:23266
So, we end up calling ggc_collect because we're processing a member
function in a context where defining a type is not allowed. One
solution would be to not do late parsing of members in such a context.
We don't have this problem with lambdas because cp_parser_lambda_body
already increments function_depth to avoid GC in the middle of an