From 42339b4608afc933ba87de057f22a1dffe15354e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Sat, 1 May 2021 05:15:44 -0700 Subject: parser: gc bug. * parser.y (set_syntax_tree): New static function. Uses GC-correct assignment via set macro. (spec): Call set_syntax_tree instead of raw assignments to parser->syntax_tree, which violate GC rules. * y.tab.c.shipped: Regenerated. --- parser.y | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'parser.y') diff --git a/parser.y b/parser.y index 98c2aa5c..3c51b69d 100644 --- a/parser.y +++ b/parser.y @@ -52,6 +52,7 @@ #include "buf.h" #include "parser.h" +static void set_syntax_tree(parser_t *parser, val tree); static val sym_helper(parser_t *parser, wchar_t *lexeme, val meta_allowed); static val repeat_rep_helper(val sym, val args, val main, val parts); static void process_catch_exprs(val exprs); @@ -170,13 +171,14 @@ INLINE val expand_form_ver(val form, int ver) %% -spec : clauses_opt { parser->syntax_tree = $1; } - | SECRET_ESCAPE_R regexpr { parser->syntax_tree = $2; end_of_regex(scnr); } +spec : clauses_opt { set_syntax_tree(parser, $1); } + | SECRET_ESCAPE_R regexpr { set_syntax_tree(parser, $2); + end_of_regex(scnr); } | SECRET_ESCAPE_E hash_semi_or_n_expr - { parser->syntax_tree = $2; YYACCEPT; } + { set_syntax_tree(parser, $2); YYACCEPT; } byacc_fool { internal_error("notreached"); } | SECRET_ESCAPE_I hash_semi_or_i_expr - { parser->syntax_tree = $2; YYACCEPT; } + { set_syntax_tree(parser, $2); YYACCEPT; } byacc_fool { internal_error("notreached"); } | SECRET_ESCAPE_E { if (yychar == YYEOF) { parser->syntax_tree = nao; @@ -1396,6 +1398,11 @@ void yydebug_onoff(int val) #endif } +static void set_syntax_tree(parser_t *parser, val tree) +{ + set(mkloc(parser->syntax_tree, parser->parser), tree); +} + static val sym_helper(parser_t *parser, wchar_t *lexeme, val meta_allowed) { scanner_t *scnr = parser->scanner; -- cgit v1.2.3