From f26f905b28c5531c78445ac15d74ca1265eff5c5 Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Sun, 20 Dec 2020 23:17:28 -0800 Subject: Mark an ISeq being JIT-ed This is to avoid SEGV on a CC reference in a normal compilation https://github.com/ruby/ruby/runs/1586578023 --- mjit.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'mjit.c') diff --git a/mjit.c b/mjit.c index 1b0fc68ee7..d87961d7cc 100644 --- a/mjit.c +++ b/mjit.c @@ -935,8 +935,13 @@ mjit_finish(bool close_handle_p) verbose(1, "Successful MJIT finish"); } -// Called by rb_vm_mark() to mark active_units so that we do not GC ISeq which -// may still be referred to by mjit_recompile() or compact_all_jit_code(). +// Called by rb_vm_mark(). +// +// Mark an ISeq being compiled to prevent its CCs from being GC-ed, which +// an MJIT worker may concurrently see. +// +// Also mark active_units so that we do not GC ISeq which may still be +// referred to by mjit_recompile() or compact_all_jit_code(). void mjit_mark(void) { @@ -944,6 +949,9 @@ mjit_mark(void) return; RUBY_MARK_ENTER("mjit"); + if (compiling_iseq != NULL) + rb_gc_mark((VALUE)compiling_iseq); + // We need to release a lock when calling rb_gc_mark to avoid doubly acquiring // a lock by by mjit_gc_start_hook inside rb_gc_mark. // -- cgit v1.2.3