summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authork0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-20 00:04:19 +0000
committerk0kubun <k0kubun@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-20 00:04:19 +0000
commit3405411cc427291e13e2cf146b730ec1b3669dce (patch)
tree0d5f8247a780aa338899c75b41f3aaf384c0a7c5
parent95e09343a400b47e2e1c1dcee4e48faece9b599e (diff)
process.c: do not try to pause MJIT
while child handler is disabled. trying to fix [Bug #15320] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--process.c27
-rw-r--r--test/ruby/test_process.rb2
2 files changed, 8 insertions, 21 deletions
diff --git a/process.c b/process.c
index b9c7c4a..6402a42 100644
--- a/process.c
+++ b/process.c
@@ -1502,26 +1502,12 @@ after_exec(void)
}
#if defined HAVE_WORKING_FORK || defined HAVE_DAEMON
+#define before_fork_ruby() before_exec()
static void
-before_fork_ruby(void)
-{
- if (mjit_enabled) {
- /* avoid leaving locked mutex and units being modified for child process. */
- mjit_pause(FALSE);
- }
-
- before_exec();
-}
-
-static void
-after_fork_ruby(int parent_p)
+after_fork_ruby(void)
{
rb_threadptr_pending_interrupt_clear(GET_THREAD());
after_exec();
-
- if (mjit_enabled && parent_p) { /* child is cared by `rb_thread_atfork` */
- mjit_resume();
- }
}
#endif
@@ -4007,12 +3993,14 @@ rb_fork_ruby(int *status)
while (1) {
prefork();
+ if (mjit_enabled) mjit_pause(FALSE); /* Don't leave locked mutex to child. Note: child_handler must be enabled to pause MJIT. */
disable_child_handler_before_fork(&old);
before_fork_ruby();
pid = fork();
err = errno;
- after_fork_ruby(pid > 0);
+ after_fork_ruby();
disable_child_handler_fork_parent(&old); /* yes, bad name */
+ if (mjit_enabled && pid > 0) mjit_resume(); /* child (pid == 0) is cared by rb_thread_atfork */
if (pid >= 0) /* fork succeed */
return pid;
/* fork failed */
@@ -6434,10 +6422,11 @@ rb_daemon(int nochdir, int noclose)
{
int err = 0;
#ifdef HAVE_DAEMON
+ if (mjit_enabled) mjit_pause(FALSE); /* Don't leave locked mutex to child. */
before_fork_ruby();
err = daemon(nochdir, noclose);
- after_fork_ruby(TRUE);
- rb_thread_atfork();
+ after_fork_ruby();
+ rb_thread_atfork(); /* calls mjit_resume() */
#else
int n;
diff --git a/test/ruby/test_process.rb b/test/ruby/test_process.rb
index 88d2a9a..4e4a657 100644
--- a/test/ruby/test_process.rb
+++ b/test/ruby/test_process.rb
@@ -1724,7 +1724,6 @@ class TestProcess < Test::Unit::TestCase
if Process.respond_to?(:daemon)
def test_daemon_default
- skip 'IO.popen deadlocks with MJIT [Bug #15320]' if RubyVM::MJIT.enabled?
data = IO.popen("-", "r+") do |f|
break f.read if f
Process.daemon
@@ -1774,7 +1773,6 @@ class TestProcess < Test::Unit::TestCase
if File.directory?("/proc/self/task") && /netbsd[a-z]*[1-6]/ !~ RUBY_PLATFORM
def test_daemon_no_threads
- skip 'IO.popen deadlocks with MJIT [Bug #15320]' if RubyVM::MJIT.enabled?
pid, data = IO.popen("-", "r+") do |f|
break f.pid, f.readlines if f
Process.daemon(true, true)