1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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.
This commit is contained in:
Aaron Patterson 2019-08-16 16:04:26 -07:00
parent cbcad66741
commit 932a471d38
No known key found for this signature in database
GPG key ID: 953170BCB4FFAFC6
2 changed files with 2 additions and 2 deletions

1
node.c
View file

@ -1184,6 +1184,7 @@ void
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

View file

@ -5807,9 +5807,8 @@ yycompile0(VALUE arg)
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;