Project

General

Profile

Bug #7570 ยป fatal_in_fiber.patch

nagachika (Tomoyuki Chikanaga), 12/16/2012 02:01 AM

View differences:

ext/-test-/fatal/extconf.rb
1
create_makefile("-test-/fatal/rb_fatal")
ext/-test-/fatal/rb_fatal.c
1
#include <ruby.h>
2

  
3
static VALUE
4
ruby_fatal(VALUE obj, VALUE msg)
5
{
6
    const char *cmsg = NULL;
7

  
8
    (void)obj;
9

  
10
    cmsg = RSTRING_PTR(msg);
11
    rb_fatal("%s", cmsg);
12
    return 0; /* never reached */
13
}
14

  
15
void
16
Init_rb_fatal(void)
17
{
18
    rb_define_method(rb_mKernel, "rb_fatal", ruby_fatal, 1);
19
}
test/ruby/test_fiber.rb
269 269
      Thread.new{ Fiber.new{ Thread.exit }.resume }.join
270 270
    end
271 271
  end
272

  
273
  def test_fatal_in_fiber
274
    assert_in_out_err(["-r-test-/fatal/rb_fatal", "-e", <<-EOS], "", [], /ok/)
275
      Fiber.new{
276
        rb_fatal "ok"
277
      }.resume
278
      puts :ng
279
    EOS
280
  end
272 281
end
273 282

  
vm.c
917 917
      case TAG_RETRY:
918 918
	result = make_localjump_error("retry outside of rescue clause", Qnil, state);
919 919
	break;
920
      case TAG_FATAL:
921
	/* internal exception or Thread.exit */
922
	/* Thread.exit set th->errinfo to INT2FIX(TAG_FATAL) */
923
	if (!FIXNUM_P(val))
924
	    result = val;
920 925
      default:
921 926
	break;
922 927
    }