Project

General

Profile

Actions

Bug #5993

closed

Thread.new{ Fiber.new { Thread.exit }.resume }.join で例外

Added by nagachika (Tomoyuki Chikanaga) about 12 years ago. Updated over 11 years ago.

Status:
Closed
Target version:
ruby -v:
ruby 2.0.0dev (2012-02-09 trunk 34514) [x86_64-darwin10.8.0]
Backport:
[ruby-dev:45218]

Description

以下のように Fiber 内で Thread.exit するとメッセージが空の RuntimeError が発生します。

Thread.new{ Fiber.new { Thread.exit }.resume }.join #=> RuntimeError:

rb_fiber_start() で Thread.exit 時の TAG_FATAL での TAG_JUMP を想定していないためだと思います。とりあえず以下のようにすると例外にならなくなります。
あと th->errinfo は空を Qnil としているのに th->thrown_errinfo は 0 (Qfalse)を空であることを示すのに使っているので、その食い違いで thrown_errinfo に Qnil を入れてしまっていた(rb_vm_make_jump_tag_but_local_jump() の結果が Qnil の時)のが原因のようなので、そちらをなんとかすべきかもしれません。全体的に thrown_errinfo も空を意味するために Qnil を使うようにそろえるとか?

--- a/cont.c
+++ b/cont.c
@@ -1152,6 +1152,9 @@ rb_fiber_start(void)
if (state == TAG_RAISE) {
th->thrown_errinfo = th->errinfo;
}

  •   else if (state == TAG_FATAL && th->errinfo == INT2FIX(TAG_FATAL)) {
    
  •       /* terminating */
    
  •   }
      else {
          th->thrown_errinfo =
            rb_vm_make_jump_tag_but_local_jump(state, th->errinfo);
    

Files

thread_exit_in_fiber.patch (1.93 KB) thread_exit_in_fiber.patch nagachika (Tomoyuki Chikanaga), 12/19/2012 02:31 AM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #6575: Thread#kill sets rb_errinfo() to Fixnum 8 after rb_protect(function, data, &error_tag)Rejectedko1 (Koichi Sasada)06/11/2012Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0