ruby-changes:50567
From: nagachika <ko1@a...>
Date: Sat, 10 Mar 2018 11:33:01 +0900 (JST)
Subject: [ruby-changes:50567] nagachika:r62711 (ruby_2_4): merge revision(s) 59963: [Backport #13163]
nagachika 2018-03-10 11:32:56 +0900 (Sat, 10 Mar 2018) New Revision: 62711 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62711 Log: merge revision(s) 59963: [Backport #13163] thread.c: report then abort * thread.c (thread_start_func_2): report then abort on exception, if both are set. [ruby-core:79280] [Bug #13163] Modified directories: branches/ruby_2_4/ Modified files: branches/ruby_2_4/test/ruby/test_thread.rb branches/ruby_2_4/thread.c branches/ruby_2_4/version.h Index: ruby_2_4/test/ruby/test_thread.rb =================================================================== --- ruby_2_4/test/ruby/test_thread.rb (revision 62710) +++ ruby_2_4/test/ruby/test_thread.rb (revision 62711) @@ -353,7 +353,8 @@ class TestThread < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/ruby/test_thread.rb#L353 end def test_report_on_exception - assert_separately([], <<~"end;") #do + assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") + begin; q1 = Thread::Queue.new q2 = Thread::Queue.new @@ -405,6 +406,19 @@ class TestThread < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/ruby/test_thread.rb#L406 assert_equal(true, q1.pop) Thread.pass while th.alive? } + + assert_warn(/report 5/, "should defaults to the global flag at the start") { + th = Thread.start { + Thread.current.report_on_exception = true + Thread.current.abort_on_exception = true + q2.pop + raise "report 5" + } + assert_raise_with_message(RuntimeError, "report 5") { + q2.push(true) + Thread.pass while th.alive? + } + } end; end Index: ruby_2_4/thread.c =================================================================== --- ruby_2_4/thread.c (revision 62710) +++ ruby_2_4/thread.c (revision 62711) @@ -630,19 +630,20 @@ thread_start_func_2(rb_thread_t *th, VAL https://github.com/ruby/ruby/blob/trunk/ruby_2_4/thread.c#L630 else if (rb_obj_is_kind_of(errinfo, rb_eSystemExit)) { /* exit on main_thread. */ } - else if (th->vm->thread_abort_on_exception || - th->abort_on_exception || RTEST(ruby_debug)) { - /* exit on main_thread */ - } - else if (th->report_on_exception) { - VALUE mesg = rb_thread_inspect(th->self); - rb_str_cat_cstr(mesg, " terminated with exception:\n"); - rb_write_error_str(mesg); - rb_threadptr_error_print(th, errinfo); - errinfo = Qnil; - } else { - errinfo = Qnil; + if (th->report_on_exception) { + VALUE mesg = rb_thread_inspect(th->self); + rb_str_cat_cstr(mesg, " terminated with exception:\n"); + rb_write_error_str(mesg); + rb_threadptr_error_print(th, errinfo); + } + if (th->vm->thread_abort_on_exception || + th->abort_on_exception || RTEST(ruby_debug)) { + /* exit on main_thread */ + } + else { + errinfo = Qnil; + } } th->value = Qnil; } Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 62710) +++ ruby_2_4/version.h (revision 62711) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.4" -#define RUBY_RELEASE_DATE "2018-03-08" -#define RUBY_PATCHLEVEL 256 +#define RUBY_RELEASE_DATE "2018-03-10" +#define RUBY_PATCHLEVEL 257 #define RUBY_RELEASE_YEAR 2018 #define RUBY_RELEASE_MONTH 3 -#define RUBY_RELEASE_DAY 8 +#define RUBY_RELEASE_DAY 10 #include "ruby/version.h" Index: ruby_2_4 =================================================================== --- ruby_2_4 (revision 62710) +++ ruby_2_4 (revision 62711) Property changes on: ruby_2_4 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r59963 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/