summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-25 17:27:37 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-25 17:27:37 +0000
commitf60e5af02dcddf1332ea2cb83e757dd77db2b504 (patch)
treee061c7d13fda0f80171d99176dd403e6a673d0cd
parentda0e21528bd64a931e2f956c216455d7180f57d8 (diff)
downloadruby-f60e5af02dcddf1332ea2cb83e757dd77db2b504.tar.gz
merge revision(s) 57595: [Backport #8996]
check thread deadness correctly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/ruby/test_thread.rb10
-rw-r--r--thread.c7
-rw-r--r--version.h2
3 files changed, 18 insertions, 1 deletions
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
index 1ef6dadf2b..57080ac6ea 100644
--- a/test/ruby/test_thread.rb
+++ b/test/ruby/test_thread.rb
@@ -1048,4 +1048,14 @@ q.pop
assert_not_predicate(status, :signaled?, FailDesc[status, bug9751, output])
assert_predicate(status, :success?, bug9751)
end if Process.respond_to?(:fork)
+
+ def test_thread_interrupt_for_killed_thread
+ assert_normal_exit(<<-_end, '[Bug #8996]', timeout: 5)
+ trap(/mswin|mignw/ =~ RUBY_PLATFORM ? :KILL : :TERM){exit}
+ while true
+ t = Thread.new{sleep 0}
+ t.raise Interrupt
+ end
+ _end
+ end
end
diff --git a/thread.c b/thread.c
index da607b2dbb..046364dfe5 100644
--- a/thread.c
+++ b/thread.c
@@ -2063,6 +2063,13 @@ rb_threadptr_raise(rb_thread_t *th, int argc, VALUE *argv)
else {
exc = rb_make_exception(argc, argv);
}
+
+ /* making an exception object can switch thread,
+ so we need to check thread deadness again */
+ if (rb_threadptr_dead(th)) {
+ return Qnil;
+ }
+
rb_threadptr_setup_exception(GET_THREAD(), exc, Qundef);
rb_threadptr_pending_interrupt_enque(th, exc);
rb_threadptr_interrupt(th);
diff --git a/version.h b/version.h
index cbc9b2e9a4..d569ac2914 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.2.7"
#define RUBY_RELEASE_DATE "2017-03-26"
-#define RUBY_PATCHLEVEL 440
+#define RUBY_PATCHLEVEL 441
#define RUBY_RELEASE_YEAR 2017
#define RUBY_RELEASE_MONTH 3