Actions
Bug #5993
closedThread.new{ Fiber.new { Thread.exit }.resume }.join で例外
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
Actions
Like0
Like0Like0Like0Like0Like0Like0Like0Like0