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

ruby-changes:48339

From: ko1 <ko1@a...>
Date: Thu, 26 Oct 2017 23:38:28 +0900 (JST)
Subject: [ruby-changes:48339] ko1:r60453 (trunk): make root fiber at switching.

ko1	2017-10-26 23:38:22 +0900 (Thu, 26 Oct 2017)

  New Revision: 60453

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60453

  Log:
    make root fiber at switching.
    
    * cont.c (fiber_switch): make sure the root fiber object is available
      before the first switching.
    
    * test/ruby/test_fiber.rb: remove "skip".

  Modified files:
    trunk/cont.c
    trunk/test/ruby/test_fiber.rb
Index: cont.c
===================================================================
--- cont.c	(revision 60452)
+++ cont.c	(revision 60453)
@@ -1521,7 +1521,10 @@ return_fiber(void) https://github.com/ruby/ruby/blob/trunk/cont.c#L1521
     rb_fiber_t *prev = fib->prev;
 
     if (!prev) {
-	rb_fiber_t *root_fiber = GET_THREAD()->root_fiber;
+	rb_thread_t *th = GET_THREAD();
+	rb_fiber_t *root_fiber = th->root_fiber;
+
+	VM_ASSERT(root_fiber != NULL);
 
 	if (root_fiber == fib) {
 	    rb_raise(rb_eFiberError, "can't yield from root fiber");
@@ -1623,6 +1626,9 @@ fiber_switch(rb_fiber_t *fib, int argc, https://github.com/ruby/ruby/blob/trunk/cont.c#L1626
     rb_context_t *cont = &fib->cont;
     rb_thread_t *th = GET_THREAD();
 
+    /* make sure the root_fiber object is available */
+    if (th->root_fiber == NULL) root_fiber_alloc(th);
+
     if (th->ec->fiber == fib) {
 	/* ignore fiber context switch
          * because destination fiber is same as current fiber
Index: test/ruby/test_fiber.rb
===================================================================
--- test/ruby/test_fiber.rb	(revision 60452)
+++ test/ruby/test_fiber.rb	(revision 60453)
@@ -184,7 +184,6 @@ class TestFiber < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_fiber.rb#L184
   end
 
   def test_fiber_transfer_segv
-    skip
     assert_normal_exit %q{
       require 'fiber'
       f2 = nil

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

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