ruby-changes:27810
From: nobu <ko1@a...>
Date: Thu, 21 Mar 2013 23:18:07 +0900 (JST)
Subject: [ruby-changes:27810] nobu:r39862 (trunk): thread.c: fix deadlock
nobu 2013-03-21 23:17:10 +0900 (Thu, 21 Mar 2013) New Revision: 39862 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39862 Log: thread.c: fix deadlock * thread.c (ruby_kill): get rid of deadlock on signal 0. [ruby-dev:47182] [Bug #8137] Modified files: trunk/ChangeLog trunk/test/ruby/test_signal.rb trunk/thread.c Index: ChangeLog =================================================================== --- ChangeLog (revision 39861) +++ ChangeLog (revision 39862) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Mar 21 23:17:08 2013 Nobuyoshi Nakada <nobu@r...> + + * thread.c (ruby_kill): get rid of deadlock on signal 0. + [ruby-dev:47182] [Bug #8137] + Thu Mar 21 23:14:15 2013 Nobuyoshi Nakada <nobu@r...> * include/ruby/ruby.h (RB_UNUSED_VAR): move code from Index: thread.c =================================================================== --- thread.c (revision 39861) +++ thread.c (revision 39862) @@ -5214,14 +5214,15 @@ ruby_kill(rb_pid_t pid, int sig) https://github.com/ruby/ruby/blob/trunk/thread.c#L5214 * When target pid is self, many caller assume signal will be * delivered immediately and synchronously. */ - if ((th == vm->main_thread) && (pid == getpid())) { + if ((sig != 0) && (th == vm->main_thread) && (pid == getpid())) { GVL_UNLOCK_BEGIN(); native_mutex_lock(&th->interrupt_lock); err = kill(pid, sig); native_cond_wait(&th->interrupt_cond, &th->interrupt_lock); native_mutex_unlock(&th->interrupt_lock); GVL_UNLOCK_END(); - } else { + } + else { err = kill(pid, sig); } if (err < 0) Index: test/ruby/test_signal.rb =================================================================== --- test/ruby/test_signal.rb (revision 39861) +++ test/ruby/test_signal.rb (revision 39862) @@ -283,7 +283,13 @@ EOS https://github.com/ruby/ruby/blob/trunk/test/ruby/test_signal.rb#L283 # This ugly workaround was introduced to don't break # compatibility against silly example codes. assert_raise(SignalException) { - Process.kill('HUP',Process.pid) + Process.kill('HUP', Process.pid) + } + bug8137 = '[ruby-dev:47182] [Bug #8137]' + assert_nothing_raised(bug8137) { + Timeout.timeout(1) { + Process.kill(0, Process.pid) + } } end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/