summaryrefslogtreecommitdiff
path: root/mjit.c
diff options
context:
space:
mode:
authork0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-22 13:29:44 +0000
committerk0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-22 13:29:44 +0000
commit2751b5366dd506bdb77a1f1a03b9c108f64eddba (patch)
tree550b93f0f9482d2325e5f17ec15f3b01ef9c3a68 /mjit.c
parent69c59f4fd07c41b478d33ff92fb95b8fd0046dc1 (diff)
mjit.c: avoid running copy job handler after ISeq GC
like this http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1471633 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'mjit.c')
-rw-r--r--mjit.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/mjit.c b/mjit.c
index 91360e8e4c..5fa93a3cfa 100644
--- a/mjit.c
+++ b/mjit.c
@@ -25,7 +25,7 @@ static void
mjit_copy_job_handler(void *data)
{
struct mjit_copy_job *job = data;
- int finish_p;
+ const struct rb_iseq_constant_body *body;
if (stop_worker_p) {
/* `copy_cache_from_main_thread()` stops to wait for this job. Then job data which is
allocated by `alloca()` could be expired and we might not be able to access that.
@@ -34,20 +34,20 @@ mjit_copy_job_handler(void *data)
}
CRITICAL_SECTION_START(3, "in mjit_copy_job_handler");
- finish_p = job->finish_p;
- CRITICAL_SECTION_FINISH(3, "in mjit_copy_job_handler");
- if (finish_p) {
- return; /* make sure that this job is never executed while job is being modified. */
+ /* Make sure that this job is never executed while job is being modified or ISeq is GC-ed */
+ if (job->finish_p || job->unit->iseq == NULL) {
+ CRITICAL_SECTION_FINISH(3, "in mjit_copy_job_handler");
+ return;
}
+ body = job->unit->iseq->body;
if (job->cc_entries) {
- memcpy(job->cc_entries, job->body->cc_entries, sizeof(struct rb_call_cache) * (job->body->ci_size + job->body->ci_kw_size));
+ memcpy(job->cc_entries, body->cc_entries, sizeof(struct rb_call_cache) * (body->ci_size + body->ci_kw_size));
}
if (job->is_entries) {
- memcpy(job->is_entries, job->body->is_entries, sizeof(union iseq_inline_storage_entry) * job->body->is_size);
+ memcpy(job->is_entries, body->is_entries, sizeof(union iseq_inline_storage_entry) * body->is_size);
}
- CRITICAL_SECTION_START(3, "in mjit_copy_job_handler");
job->finish_p = TRUE;
rb_native_cond_broadcast(&mjit_worker_wakeup);
CRITICAL_SECTION_FINISH(3, "in mjit_copy_job_handler");