summaryrefslogtreecommitdiff
path: root/cont.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-26 14:38:22 (GMT)
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-26 14:38:22 (GMT)
commitd77305fc9cdf295bee3d6d6148dfc602291ad91f (patch)
treeff617e907bb281d80f3643d4e9f1c426d99d3bf8 /cont.c
parentd717dafc0e928228dcdc42242b2b8e7d3881cd22 (diff)
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
Diffstat (limited to 'cont.c')
-rw-r--r--cont.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/cont.c b/cont.c
index d0f9f27..bc0c1fa 100644
--- a/cont.c
+++ b/cont.c
@@ -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