ruby-changes:44491
From: nagachika <ko1@a...>
Date: Sat, 5 Nov 2016 11:44:11 +0900 (JST)
Subject: [ruby-changes:44491] nagachika:r56564 (ruby_2_3): merge revision(s) 53449: [Backport #11959]
nagachika 2016-11-05 11:44:06 +0900 (Sat, 05 Nov 2016) New Revision: 56564 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56564 Log: 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] Modified directories: branches/ruby_2_3/ Modified files: branches/ruby_2_3/ChangeLog branches/ruby_2_3/test/ruby/test_thread.rb branches/ruby_2_3/thread.c branches/ruby_2_3/version.h Index: ruby_2_3/test/ruby/test_thread.rb =================================================================== --- ruby_2_3/test/ruby/test_thread.rb (revision 56563) +++ ruby_2_3/test/ruby/test_thread.rb (revision 56564) @@ -748,9 +748,24 @@ _eom https://github.com/ruby/ruby/blob/trunk/ruby_2_3/test/ruby/test_thread.rb#L748 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 Index: ruby_2_3/ChangeLog =================================================================== --- ruby_2_3/ChangeLog (revision 56563) +++ ruby_2_3/ChangeLog (revision 56564) @@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/ChangeLog#L1 +Sat Nov 5 11:35:58 2016 Nobuyoshi Nakada <nobu@r...> + + * 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] + Sat Nov 5 11:16:58 2016 Kenta Murata <mrkn@m...> * ext/bigdecimal/bigdecimal.c: Import changes from ruby/bigdecimal Index: ruby_2_3/thread.c =================================================================== --- ruby_2_3/thread.c (revision 56563) +++ ruby_2_3/thread.c (revision 56564) @@ -1561,6 +1561,14 @@ rb_threadptr_pending_interrupt_enque(rb_ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/thread.c#L1561 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, @@ -1868,6 +1876,9 @@ rb_thread_pending_interrupt_p(int argc, https://github.com/ruby/ruby/blob/trunk/ruby_2_3/thread.c#L1876 GetThreadPtr(target_thread, target_th); + if (!target_th->pending_interrupt_queue) { + return Qfalse; + } if (rb_threadptr_pending_interrupt_empty_p(target_th)) { return Qfalse; } @@ -2181,6 +2192,7 @@ thread_raise_m(int argc, VALUE *argv, VA https://github.com/ruby/ruby/blob/trunk/ruby_2_3/thread.c#L2192 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 */ @@ -2225,6 +2237,7 @@ rb_thread_kill(VALUE thread) https://github.com/ruby/ruby/blob/trunk/ruby_2_3/thread.c#L2237 rb_threadptr_to_kill(th); } else { + threadptr_check_pending_interrupt_queue(th); rb_threadptr_pending_interrupt_enque(th, eKillSignal); rb_threadptr_interrupt(th); } Index: ruby_2_3/version.h =================================================================== --- ruby_2_3/version.h (revision 56563) +++ ruby_2_3/version.h (revision 56564) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_3/version.h#L1 #define RUBY_VERSION "2.3.2" #define RUBY_RELEASE_DATE "2016-11-05" -#define RUBY_PATCHLEVEL 201 +#define RUBY_PATCHLEVEL 202 #define RUBY_RELEASE_YEAR 2016 #define RUBY_RELEASE_MONTH 11 Property changes on: ruby_2_3 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r53449 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/