1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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".


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2017-10-26 14:38:22 +00:00
parent d717dafc0e
commit d77305fc9c
2 changed files with 7 additions and 2 deletions

8
cont.c
View file

@ -1521,7 +1521,10 @@ return_fiber(void)
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, const VALUE *argv, int is_resume)
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

View file

@ -184,7 +184,6 @@ class TestFiber < Test::Unit::TestCase
end
def test_fiber_transfer_segv
skip
assert_normal_exit %q{
require 'fiber'
f2 = nil