Bug #7570 ยป fatal_in_fiber.patch
ext/-test-/fatal/extconf.rb | ||
---|---|---|
create_makefile("-test-/fatal/rb_fatal")
|
ext/-test-/fatal/rb_fatal.c | ||
---|---|---|
#include <ruby.h>
|
||
static VALUE
|
||
ruby_fatal(VALUE obj, VALUE msg)
|
||
{
|
||
const char *cmsg = NULL;
|
||
(void)obj;
|
||
cmsg = RSTRING_PTR(msg);
|
||
rb_fatal("%s", cmsg);
|
||
return 0; /* never reached */
|
||
}
|
||
void
|
||
Init_rb_fatal(void)
|
||
{
|
||
rb_define_method(rb_mKernel, "rb_fatal", ruby_fatal, 1);
|
||
}
|
test/ruby/test_fiber.rb | ||
---|---|---|
Thread.new{ Fiber.new{ Thread.exit }.resume }.join
|
||
end
|
||
end
|
||
def test_fatal_in_fiber
|
||
assert_in_out_err(["-r-test-/fatal/rb_fatal", "-e", <<-EOS], "", [], /ok/)
|
||
Fiber.new{
|
||
rb_fatal "ok"
|
||
}.resume
|
||
puts :ng
|
||
EOS
|
||
end
|
||
end
|
||
vm.c | ||
---|---|---|
case TAG_RETRY:
|
||
result = make_localjump_error("retry outside of rescue clause", Qnil, state);
|
||
break;
|
||
case TAG_FATAL:
|
||
/* internal exception or Thread.exit */
|
||
/* Thread.exit set th->errinfo to INT2FIX(TAG_FATAL) */
|
||
if (!FIXNUM_P(val))
|
||
result = val;
|
||
default:
|
||
break;
|
||
}
|