Project

General

Profile

Feature #14143 ยป 0001-Set-Thread.report_on_exception-true-by-default-to-re.patch

Eregon (Benoit Daloze), 12/12/2017 02:05 PM

View differences:

spec/ruby/core/thread/report_on_exception_spec.rb
2 2

  
3 3
ruby_version_is "2.4" do
4 4
  describe "Thread.report_on_exception" do
5
    it "defaults to false" do
6
      ruby_exe("p Thread.report_on_exception").should == "false\n"
5
    ruby_version_is "2.4"..."2.5" do
6
      it "defaults to false" do
7
        ruby_exe("p Thread.report_on_exception").should == "false\n"
8
      end
9
    end
10

  
11
    ruby_version_is "2.5" do
12
      it "defaults to true" do
13
        ruby_exe("p Thread.report_on_exception").should == "true\n"
14
      end
7 15
    end
8 16
  end
9 17

  
test/lib/test/unit.rb
9 9
require 'test/unit/testcase'
10 10
require 'optparse'
11 11

  
12
# eregon: temporary until test-all is fixed to not produce dead Thread warnings
13
Thread.report_on_exception = false
14

  
12 15
# See Test::Unit
13 16
module Test
14 17
  ##
test/ruby/test_exception.rb
354 354
  def test_thread_signal_location
355 355
    _, stderr, _ = EnvUtil.invoke_ruby(%w"--disable-gems -d", <<-RUBY, false, true)
356 356
Thread.start do
357
  Thread.current.report_on_exception = false
357 358
  begin
358 359
    Process.kill(:INT, $$)
359 360
  ensure
test/ruby/test_thread.rb
317 317
    assert_in_out_err([], <<-INPUT, %w(false 1), [])
318 318
      p Thread.abort_on_exception
319 319
      begin
320
        t = Thread.new { raise }
320
        t = Thread.new {
321
          Thread.current.report_on_exception = false
322
          raise
323
        }
321 324
        Thread.pass until t.stop?
322 325
        p 1
323 326
      rescue
......
329 332
      Thread.abort_on_exception = true
330 333
      p Thread.abort_on_exception
331 334
      begin
332
        Thread.new { raise }
335
        Thread.new {
336
          Thread.current.report_on_exception = false
337
          raise
338
        }
333 339
        sleep 0.5
334 340
        p 1
335 341
      rescue
......
352 358
      p Thread.abort_on_exception
353 359
      begin
354 360
        ok = false
355
        t = Thread.new { Thread.pass until ok; raise }
361
        t = Thread.new {
362
          Thread.current.report_on_exception = false
363
          Thread.pass until ok
364
          raise
365
        }
356 366
        t.abort_on_exception = true
357 367
        p t.abort_on_exception
358 368
        ok = 1
......
780 790
      th_waiting = true
781 791

  
782 792
      t = Thread.new {
793
        Thread.current.report_on_exception = false
783 794
        Thread.handle_interrupt(RuntimeError => :on_blocking) {
784 795
          nil while th_waiting
785 796
          # async interrupt should be raised _before_ writing puts arguments
......
800 811
      th_waiting = false
801 812

  
802 813
      t = Thread.new {
814
        Thread.current.report_on_exception = false
803 815
        Thread.handle_interrupt(RuntimeError => :on_blocking) {
804 816
          th_waiting = true
805 817
          nil while th_waiting
thread.c
648 648
	    else {
649 649
		if (th->report_on_exception) {
650 650
		    VALUE mesg = rb_thread_to_s(th->self);
651
		    rb_str_cat_cstr(mesg, " terminated with exception:\n");
651
		    rb_str_cat_cstr(mesg, " terminated with exception (report_on_exception is true):\n");
652 652
		    rb_write_error_str(mesg);
653 653
		    rb_ec_error_print(th->ec, errinfo);
654 654
		}
vm.c
2280 2280
{
2281 2281
    MEMZERO(vm, rb_vm_t, 1);
2282 2282
    rb_vm_living_threads_init(vm);
2283
    vm->thread_report_on_exception = 1;
2283 2284
    vm->src_encoding_index = -1;
2284 2285

  
2285 2286
    vm_default_params_setup(vm);
2286
-