summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mjit.c10
-rw-r--r--mjit_worker.c3
2 files changed, 12 insertions, 1 deletions
diff --git a/mjit.c b/mjit.c
index 215057ae30..888f0461aa 100644
--- a/mjit.c
+++ b/mjit.c
@@ -24,7 +24,15 @@
static void
mjit_copy_job_handler(void *data)
{
- struct mjit_copy_job *job = (struct mjit_copy_job *)data;
+ struct mjit_copy_job *job;
+ 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. */
+ return;
+ }
+
+ job = (struct mjit_copy_job *)data;
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));
}
diff --git a/mjit_worker.c b/mjit_worker.c
index b25dc6f190..41d07f0dd7 100644
--- a/mjit_worker.c
+++ b/mjit_worker.c
@@ -1182,6 +1182,9 @@ copy_cache_from_main_thread(struct mjit_copy_job *job)
return FALSE;
CRITICAL_SECTION_START(3, "in MJIT copy job wait");
+ /* checking `stop_worker_p` too because `RUBY_VM_CHECK_INTS(ec)` may not
+ lush mjit_copy_job_handler when EC_EXEC_TAG() is not TAG_NONE, and then
+ `stop_worker()` could dead lock with this function. */
while (!job->finish_p && !stop_worker_p) {
rb_native_cond_wait(&mjit_worker_wakeup, &mjit_engine_mutex);
verbose(3, "Getting wakeup from client");