aboutsummaryrefslogtreecommitdiffstats
path: root/mjit.c
diff options
context:
space:
mode:
authorTakashi Kokubun <takashikkbn@gmail.com>2020-12-15 23:14:02 -0800
committerTakashi Kokubun <takashikkbn@gmail.com>2020-12-16 00:22:50 -0800
commit5d8f227d0edd3c542fcac465eb82005a5f852d34 (patch)
treedc2c1a52d701766fa8d71ab1dd28483acd5e6b55 /mjit.c
parent0a521618723e5e602c1288b4185b869e94332172 (diff)
downloadruby-5d8f227d0edd3c542fcac465eb82005a5f852d34.tar.gz
Lazily move units from active_units to stale_units
to avoid SEGV like http://ci.rvm.jp/results/trunk-mjit@phosphorus-docker/3289588 by a race condition between mjit_recompile and compation around active_units
Diffstat (limited to 'mjit.c')
-rw-r--r--mjit.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/mjit.c b/mjit.c
index 34f83a4633..2b6ceba2d3 100644
--- a/mjit.c
+++ b/mjit.c
@@ -333,12 +333,13 @@ mjit_recompile(const rb_iseq_t *iseq)
verbose(1, "JIT recompile: %s@%s:%d", RSTRING_PTR(iseq->body->location.label),
RSTRING_PTR(rb_iseq_path(iseq)), FIX2INT(iseq->body->location.first_lineno));
+ // Lazily move active_units to stale_units to avoid race conditions around active_units with compaction
CRITICAL_SECTION_START(3, "in rb_mjit_recompile_iseq");
- remove_from_list(iseq->body->jit_unit, &active_units);
- iseq->body->jit_func = (mjit_func_t)NOT_ADDED_JIT_ISEQ_FUNC;
- add_to_list(iseq->body->jit_unit, &stale_units);
+ iseq->body->jit_unit->stale_p = true;
+ pending_stale_p = true;
CRITICAL_SECTION_FINISH(3, "in rb_mjit_recompile_iseq");
+ iseq->body->jit_func = (mjit_func_t)NOT_ADDED_JIT_ISEQ_FUNC;
mjit_add_iseq_to_process(iseq, &iseq->body->jit_unit->compile_info);
if (UNLIKELY(mjit_opts.wait)) {
mjit_wait(iseq->body);