diff options
author | Takashi Kokubun <[email protected]> | 2020-12-15 23:14:02 -0800 |
---|---|---|
committer | Takashi Kokubun <[email protected]> | 2020-12-16 00:22:50 -0800 |
commit | 5d8f227d0edd3c542fcac465eb82005a5f852d34 (patch) | |
tree | dc2c1a52d701766fa8d71ab1dd28483acd5e6b55 /mjit.c | |
parent | 0a521618723e5e602c1288b4185b869e94332172 (diff) |
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.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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); |