ruby-changes:70844
From: Yusuke <ko1@a...>
Date: Thu, 13 Jan 2022 03:22:09 +0900 (JST)
Subject: [ruby-changes:70844] ae5458f228 (master): thread.c: Convert TAG_BREAK to a normal exception at thread top-level
https://git.ruby-lang.org/ruby.git/commit/?id=ae5458f228 From ae5458f228a5477383e9c00425d85d50a3867817 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Wed, 12 Jan 2022 17:29:17 +0900 Subject: thread.c: Convert TAG_BREAK to a normal exception at thread top-level [Bug #18475] --- test/ruby/test_enum.rb | 11 +++++++++++ thread.c | 3 +++ 2 files changed, 14 insertions(+) diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb index f6375a4ffc2..b0c43b9a7fa 100644 --- a/test/ruby/test_enum.rb +++ b/test/ruby/test_enum.rb @@ -461,6 +461,17 @@ class TestEnumerable < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_enum.rb#L461 empty.first empty.block.call end; + + bug18475 = '[ruby-dev:107059]' + assert_in_out_err([], <<-'end;', [], /unexpected break/, bug18475) + e = Enumerator.new do |g| + Thread.new do + g << 1 + end.join + end + + e.first + end; end def test_sort diff --git a/thread.c b/thread.c index 36723c6fc06..cf6e89327ef 100644 --- a/thread.c +++ b/thread.c @@ -830,6 +830,9 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start) https://github.com/ruby/ruby/blob/trunk/thread.c#L830 else { errinfo = th->ec->errinfo; + VALUE exc = rb_vm_make_jump_tag_but_local_jump(state, Qundef); + if (!NIL_P(exc)) errinfo = exc; + if (state == TAG_FATAL) { if (th->invoke_type == thread_invoke_type_ractor_proc) { rb_ractor_atexit(th->ec, Qnil); -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/