summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-11 22:33:21 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-11 22:33:21 +0000
commit604f8be1571b9b0857c86a8c963f2d96fa8b92ba (patch)
tree7bb942fc76a59124e3f148d3b047987eba110116
parent04b031656add2a8c9f7f2136e4fc7fc16c9ac901 (diff)
merge revision(s) 53449: [Backport #11959]
* thread.c (rb_thread_pending_interrupt_p): no pending interrupt before initialization. * thread.c (thread_raise_m, rb_thread_kill): uninitialized thread cannot interrupt. [ruby-core:72732] [Bug #11959] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@56726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--test/ruby/test_thread.rb19
-rw-r--r--thread.c13
-rw-r--r--version.h8
4 files changed, 42 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index f143089b4d..33f39df6f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Sat Nov 12 07:32:23 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * thread.c (rb_thread_pending_interrupt_p): no pending interrupt
+ before initialization.
+
+ * thread.c (thread_raise_m, rb_thread_kill): uninitialized thread
+ cannot interrupt. [ruby-core:72732] [Bug #11959]
+
Thu Oct 27 16:47:57 2016 Kazuki Yamaguchi <k@rhe.jp>
* eval_intern.h (TH_PUSH_TAG): Initialize struct rb_vm_tag::tag with
diff --git a/test/ruby/test_thread.rb b/test/ruby/test_thread.rb
index 87d5f0f79e..1ef6dadf2b 100644
--- a/test/ruby/test_thread.rb
+++ b/test/ruby/test_thread.rb
@@ -744,9 +744,24 @@ _eom
end
def test_uninitialized
- c = Class.new(Thread)
- c.class_eval { def initialize; end }
+ c = Class.new(Thread) {def initialize; end}
assert_raise(ThreadError) { c.new.start }
+
+ bug11959 = '[ruby-core:72732] [Bug #11959]'
+
+ c = Class.new(Thread) {def initialize; exit; end}
+ assert_raise(ThreadError, bug11959) { c.new }
+
+ c = Class.new(Thread) {def initialize; raise; end}
+ assert_raise(ThreadError, bug11959) { c.new }
+
+ c = Class.new(Thread) {
+ def initialize
+ pending = pending_interrupt?
+ super {pending}
+ end
+ }
+ assert_equal(false, c.new.value, bug11959)
end
def test_backtrace
diff --git a/thread.c b/thread.c
index b6c5b35693..ba521284f7 100644
--- a/thread.c
+++ b/thread.c
@@ -1546,6 +1546,14 @@ rb_threadptr_pending_interrupt_enque(rb_thread_t *th, VALUE v)
th->pending_interrupt_queue_checked = 0;
}
+static void
+threadptr_check_pending_interrupt_queue(rb_thread_t *th)
+{
+ if (!th->pending_interrupt_queue) {
+ rb_raise(rb_eThreadError, "uninitialized thread");
+ }
+}
+
enum handle_interrupt_timing {
INTERRUPT_NONE,
INTERRUPT_IMMEDIATE,
@@ -1841,6 +1849,9 @@ rb_thread_pending_interrupt_p(int argc, VALUE *argv, VALUE target_thread)
GetThreadPtr(target_thread, target_th);
+ if (!target_th->pending_interrupt_queue) {
+ return Qfalse;
+ }
if (rb_threadptr_pending_interrupt_empty_p(target_th)) {
return Qfalse;
}
@@ -2154,6 +2165,7 @@ thread_raise_m(int argc, VALUE *argv, VALUE self)
rb_thread_t *target_th;
rb_thread_t *th = GET_THREAD();
GetThreadPtr(self, target_th);
+ threadptr_check_pending_interrupt_queue(target_th);
rb_threadptr_raise(target_th, argc, argv);
/* To perform Thread.current.raise as Kernel.raise */
@@ -2198,6 +2210,7 @@ rb_thread_kill(VALUE thread)
rb_threadptr_to_kill(th);
}
else {
+ threadptr_check_pending_interrupt_queue(th);
rb_threadptr_pending_interrupt_enque(th, eKillSignal);
rb_threadptr_interrupt(th);
}
diff --git a/version.h b/version.h
index ee3080693e..c04f6e3872 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@
#define RUBY_VERSION "2.2.6"
-#define RUBY_RELEASE_DATE "2016-10-27"
-#define RUBY_PATCHLEVEL 384
+#define RUBY_RELEASE_DATE "2016-11-12"
+#define RUBY_PATCHLEVEL 385
#define RUBY_RELEASE_YEAR 2016
-#define RUBY_RELEASE_MONTH 10
-#define RUBY_RELEASE_DAY 27
+#define RUBY_RELEASE_MONTH 11
+#define RUBY_RELEASE_DAY 12
#include "ruby/version.h"