[前][次][番号順一覧][スレッド一覧]

ruby-changes:26390

From: nagachika <ko1@a...>
Date: Tue, 18 Dec 2012 13:30:57 +0900 (JST)
Subject: [ruby-changes:26390] nagachika:r38441 (trunk): * vm.c (rb_vm_make_jump_tag_but_local_jump): take care of the case

nagachika	2012-12-18 13:30:44 +0900 (Tue, 18 Dec 2012)

  New Revision: 38441

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38441

  Log:
    * 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.

  Added directories:
    trunk/ext/-test-/fatal/
  Added files:
    trunk/ext/-test-/fatal/extconf.rb
    trunk/ext/-test-/fatal/rb_fatal.c
  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_fiber.rb
    trunk/vm.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38440)
+++ ChangeLog	(revision 38441)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Dec 18 09:45:14 2012  CHIKANAGA Tomoyuki  <nagachika@r...>
+
+	* 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@z...>
 
 	* vm_trace.c (tracepoint_attr_defined_class): Clean up rdoc for
Index: ext/-test-/fatal/extconf.rb
===================================================================
--- ext/-test-/fatal/extconf.rb	(revision 0)
+++ ext/-test-/fatal/extconf.rb	(revision 38441)
@@ -0,0 +1 @@
+create_makefile("-test-/fatal/rb_fatal")
Index: ext/-test-/fatal/rb_fatal.c
===================================================================
--- ext/-test-/fatal/rb_fatal.c	(revision 0)
+++ ext/-test-/fatal/rb_fatal.c	(revision 38441)
@@ -0,0 +1,19 @@ https://github.com/ruby/ruby/blob/trunk/ext/-test-/fatal/rb_fatal.c#L1
+#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);
+}
Index: vm.c
===================================================================
--- vm.c	(revision 38440)
+++ vm.c	(revision 38441)
@@ -917,6 +917,11 @@ rb_vm_make_jump_tag_but_local_jump(int s https://github.com/ruby/ruby/blob/trunk/vm.c#L917
       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;
     }
Index: test/ruby/test_fiber.rb
===================================================================
--- test/ruby/test_fiber.rb	(revision 38440)
+++ test/ruby/test_fiber.rb	(revision 38441)
@@ -269,5 +269,14 @@ class TestFiber < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_fiber.rb#L269
       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 # unreachable.
+    EOS
+  end
 end
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]