ruby-changes:50534
From: nobu <ko1@a...>
Date: Tue, 6 Mar 2018 14:16:02 +0900 (JST)
Subject: [ruby-changes:50534] nobu:r62673 (trunk): thread.c: deadlock in backtrace
nobu 2018-03-06 14:15:57 +0900 (Tue, 06 Mar 2018) New Revision: 62673 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62673 Log: thread.c: deadlock in backtrace * thread.c (unblock_function_set): check interrupts just once during raising exceptions, as they are deferred since r16651. [ruby-core:85939] [Bug #14577] Modified files: trunk/test/ruby/test_exception.rb trunk/thread.c Index: thread.c =================================================================== --- thread.c (revision 62672) +++ thread.c (revision 62673) @@ -428,7 +428,7 @@ unblock_function_set(rb_thread_t *th, rb https://github.com/ruby/ruby/blob/trunk/thread.c#L428 } rb_native_mutex_lock(&th->interrupt_lock); - } while (RUBY_VM_INTERRUPTED_ANY(th->ec) && + } while (!th->ec->raised_flag && RUBY_VM_INTERRUPTED_ANY(th->ec) && (rb_native_mutex_unlock(&th->interrupt_lock), TRUE)); VM_ASSERT(th->unblock.func == NULL); Index: test/ruby/test_exception.rb =================================================================== --- test/ruby/test_exception.rb (revision 62672) +++ test/ruby/test_exception.rb (revision 62673) @@ -1200,6 +1200,28 @@ $stderr = $stdout; raise "\x82\xa0"') do https://github.com/ruby/ruby/blob/trunk/test/ruby/test_exception.rb#L1200 end; end + def test_blocking_backtrace + assert_separately([], "#{<<~"begin;"}\n#{<<~'end;'}") + begin; + class Bug < RuntimeError + def backtrace + IO.readlines(IO::NULL) + end + end + bug = Bug.new '[ruby-core:85939] [Bug #14577]' + n = 10000 + i = 0 + n.times do + begin + raise bug + rescue Bug + i += 1 + end + end + assert_equal(n, i) + end; + end + def test_wrong_backtrace assert_separately([], "#{<<-"begin;"}\n#{<<-"end;"}") begin; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/