зеркало из https://github.com/github/ruby.git
* vm.c (rb_vm_make_jump_tag_but_local_jump): take care of the case
TAG_JUMP() with TAG_FATAL (ex. rb_fatal()). * test/ruby/test_fiber.rb (test_fatal_in_fiber): add a test for above. * ext/-test-/fatal/extconf.rb, ext/-test-/fatal/rb_fatal.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
ec3226d826
Коммит
606b66db7d
|
@ -1,3 +1,12 @@
|
||||||
|
Tue Dec 18 09:45:14 2012 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org>
|
||||||
|
|
||||||
|
* vm.c (rb_vm_make_jump_tag_but_local_jump): take care of the case
|
||||||
|
TAG_JUMP() with TAG_FATAL (ex. rb_fatal()).
|
||||||
|
|
||||||
|
* test/ruby/test_fiber.rb (test_fatal_in_fiber): add a test for above.
|
||||||
|
|
||||||
|
* ext/-test-/fatal/extconf.rb, ext/-test-/fatal/rb_fatal.c: ditto.
|
||||||
|
|
||||||
Tue Dec 18 13:17:00 2012 Zachary Scott <zachary@zacharyscott.net>
|
Tue Dec 18 13:17:00 2012 Zachary Scott <zachary@zacharyscott.net>
|
||||||
|
|
||||||
* vm_trace.c (tracepoint_attr_defined_class): Clean up rdoc for
|
* vm_trace.c (tracepoint_attr_defined_class): Clean up rdoc for
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
create_makefile("-test-/fatal/rb_fatal")
|
|
@ -0,0 +1,19 @@
|
||||||
|
#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);
|
||||||
|
}
|
|
@ -269,5 +269,14 @@ class TestFiber < Test::Unit::TestCase
|
||||||
Thread.new{ Fiber.new{ Thread.exit }.resume }.join
|
Thread.new{ Fiber.new{ Thread.exit }.resume }.join
|
||||||
end
|
end
|
||||||
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 # unreachable.
|
||||||
|
EOS
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
5
vm.c
5
vm.c
|
@ -917,6 +917,11 @@ rb_vm_make_jump_tag_but_local_jump(int state, VALUE val)
|
||||||
case TAG_RETRY:
|
case TAG_RETRY:
|
||||||
result = make_localjump_error("retry outside of rescue clause", Qnil, state);
|
result = make_localjump_error("retry outside of rescue clause", Qnil, state);
|
||||||
break;
|
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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче