summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authork0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-19 13:33:07 +0000
committerk0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-19 13:33:07 +0000
commite205cd80d2e4a4b77a06b74758dfd566d7c0b719 (patch)
tree64cd006976b962a3eb67e731c024a1498918f89d
parent759cfd3bcb9d940ed9c11330cc995aacc2e12fe4 (diff)
process.c: do not run signal handler before fork
to prevent from proceeding one for MJIT while it's not safe yet. By that situation, MJIT worker could be waiting for compiler process forever http://ci.rvm.jp/results/trunk-mjit@silicon-docker/1468033 [Bug #15320] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--internal.h1
-rw-r--r--mjit.c15
-rw-r--r--process.c5
3 files changed, 15 insertions, 6 deletions
diff --git a/internal.h b/internal.h
index d36723b273..6b00cbedc5 100644
--- a/internal.h
+++ b/internal.h
@@ -1633,6 +1633,7 @@ VALUE rb_math_sqrt(VALUE);
#if USE_MJIT
extern int mjit_enabled;
VALUE mjit_pause(int wait_p);
+void mjit_pause_without_ints(void);
VALUE mjit_resume(void);
#else
#define mjit_enabled 0
diff --git a/mjit.c b/mjit.c
index 1578c961ae..9c2cfcfedf 100644
--- a/mjit.c
+++ b/mjit.c
@@ -677,7 +677,7 @@ mjit_init(struct mjit_options *opts)
}
static void
-stop_worker(void)
+stop_worker(int check_ints_p)
{
rb_execution_context_t *ec = GET_EC();
@@ -687,10 +687,17 @@ stop_worker(void)
stop_worker_p = TRUE; /* Setting this inside loop because RUBY_VM_CHECK_INTS may make this FALSE. */
rb_native_cond_broadcast(&mjit_worker_wakeup);
CRITICAL_SECTION_FINISH(3, "in stop_worker");
- RUBY_VM_CHECK_INTS(ec);
+ if (check_ints_p) RUBY_VM_CHECK_INTS(ec);
}
}
+/* A function to stop MJIT worker when it's not safe to allow interrupts. */
+void
+mjit_pause_without_ints(void)
+{
+ stop_worker(FALSE);
+}
+
/* Stop JIT-compiling methods but compiled code is kept available. */
VALUE
mjit_pause(int wait_p)
@@ -716,7 +723,7 @@ mjit_pause(int wait_p)
}
}
- stop_worker();
+ stop_worker(TRUE);
return Qtrue;
}
@@ -809,7 +816,7 @@ mjit_finish(void)
CRITICAL_SECTION_FINISH(3, "in mjit_finish to wakeup from pch");
/* Stop worker */
- stop_worker();
+ stop_worker(TRUE);
rb_native_mutex_destroy(&mjit_engine_mutex);
rb_native_cond_destroy(&mjit_pch_wakeup);
diff --git a/process.c b/process.c
index b9c7c4a151..16387551d1 100644
--- a/process.c
+++ b/process.c
@@ -1506,8 +1506,9 @@ static void
before_fork_ruby(void)
{
if (mjit_enabled) {
- /* avoid leaving locked mutex and units being modified for child process. */
- mjit_pause(FALSE);
+ /* Avoid leaving locked mutex and units being modified for child process. Here may not be
+ safe for proceeding SIGCHLD handler, so this does not allow RUBY_VM_CHECK_INTS. */
+ mjit_pause_without_ints();
}
before_exec();