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
ruby_version_is "2.4" do
describe "Thread.report_on_exception" do
it "defaults to false" do
ruby_exe("p Thread.report_on_exception").should == "false\n"
ruby_version_is "2.4"..."2.5" do
it "defaults to false" do
ruby_exe("p Thread.report_on_exception").should == "false\n"
end
end
ruby_version_is "2.5" do
it "defaults to true" do
ruby_exe("p Thread.report_on_exception").should == "true\n"
end
end
end
test/lib/test/unit.rb
require 'test/unit/testcase'
require 'optparse'
# eregon: temporary until test-all is fixed to not produce dead Thread warnings
Thread.report_on_exception = false
# See Test::Unit
module Test
##
test/ruby/test_exception.rb
def test_thread_signal_location
_, stderr, _ = EnvUtil.invoke_ruby(%w"--disable-gems -d", <<-RUBY, false, true)
Thread.start do
Thread.current.report_on_exception = false
begin
Process.kill(:INT, $$)
ensure
test/ruby/test_thread.rb
assert_in_out_err([], <<-INPUT, %w(false 1), [])
p Thread.abort_on_exception
begin
t = Thread.new { raise }
t = Thread.new {
Thread.current.report_on_exception = false
raise
}
Thread.pass until t.stop?
p 1
rescue
......
Thread.abort_on_exception = true
p Thread.abort_on_exception
begin
Thread.new { raise }
Thread.new {
Thread.current.report_on_exception = false
raise
}
sleep 0.5
p 1
rescue
......
p Thread.abort_on_exception
begin
ok = false
t = Thread.new { Thread.pass until ok; raise }
t = Thread.new {
Thread.current.report_on_exception = false
Thread.pass until ok
raise
}
t.abort_on_exception = true
p t.abort_on_exception
ok = 1
......
th_waiting = true
t = Thread.new {
Thread.current.report_on_exception = false
Thread.handle_interrupt(RuntimeError => :on_blocking) {
nil while th_waiting
# async interrupt should be raised _before_ writing puts arguments
......
th_waiting = false
t = Thread.new {
Thread.current.report_on_exception = false
Thread.handle_interrupt(RuntimeError => :on_blocking) {
th_waiting = true
nil while th_waiting
thread.c
else {
if (th->report_on_exception) {
VALUE mesg = rb_thread_to_s(th->self);
rb_str_cat_cstr(mesg, " terminated with exception:\n");
rb_str_cat_cstr(mesg, " terminated with exception (report_on_exception is true):\n");
rb_write_error_str(mesg);
rb_ec_error_print(th->ec, errinfo);
}
vm.c
{
MEMZERO(vm, rb_vm_t, 1);
rb_vm_living_threads_init(vm);
vm->thread_report_on_exception = 1;
vm->src_encoding_index = -1;
vm_default_params_setup(vm);
    (1-1/1)