summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/ruby/test_exception.rb22
-rw-r--r--thread.c2
2 files changed, 23 insertions, 1 deletions
diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb
index 08e581d4f4..bb70bf508f 100644
--- a/test/ruby/test_exception.rb
+++ b/test/ruby/test_exception.rb
@@ -1200,6 +1200,28 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status|
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;
diff --git a/thread.c b/thread.c
index 2c06127292..ea0f526d2e 100644
--- a/thread.c
+++ b/thread.c
@@ -428,7 +428,7 @@ unblock_function_set(rb_thread_t *th, rb_unblock_function_t *func, void *arg, in
}
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);