ruby-changes:57345
From: Aaron <ko1@a...>
Date: Wed, 28 Aug 2019 03:43:42 +0900 (JST)
Subject: [ruby-changes:57345] Aaron Patterson: 932a471d38 (master): Directly mark compile options from the AST object
https://git.ruby-lang.org/ruby.git/commit/?id=932a471d38 From 932a471d3811d6d44764ce42b1b140a04961a763 Mon Sep 17 00:00:00 2001 From: Aaron Patterson <tenderlove@r...> Date: Fri, 16 Aug 2019 16:04:26 -0700 Subject: Directly mark compile options from the AST object `rb_ast_t` holds a reference to this object, so it should mark the object. Currently it is relying on the `mark_ary` on `node_buffer` to ensure that the object stays alive. But since the array internals can move, this could cause a segv if compaction impacts the array. diff --git a/node.c b/node.c index 9955831..4c2810b 100644 --- a/node.c +++ b/node.c @@ -1184,6 +1184,7 @@ void https://github.com/ruby/ruby/blob/trunk/node.c#L1184 rb_ast_mark(rb_ast_t *ast) { if (ast->node_buffer) rb_gc_mark(ast->node_buffer->mark_ary); + if (ast->body.compile_option) rb_gc_mark(ast->body.compile_option); } void diff --git a/parse.y b/parse.y index 0edbc56..ade2e0a 100644 --- a/parse.y +++ b/parse.y @@ -5807,9 +5807,8 @@ yycompile0(VALUE arg) https://github.com/ruby/ruby/blob/trunk/parse.y#L5807 if (!opt) opt = rb_obj_hide(rb_ident_hash_new()); rb_hash_aset(opt, rb_sym_intern_ascii_cstr("coverage_enabled"), cov); prelude = block_append(p, p->eval_tree_begin, body); - add_mark_object(p, opt); tree->nd_body = prelude; - p->ast->body.compile_option = opt; + RB_OBJ_WRITE(p->ast, &p->ast->body.compile_option, opt); } p->ast->body.root = tree; p->ast->body.line_count = p->line_count; -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/