aboutsummaryrefslogtreecommitdiffstats
path: root/test/ruby/test_fiber.rb
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-03 10:21:47 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-04-03 10:21:47 +0000
commit6c33234d38ccf763537cd779c7af9eeaac7aa7fd (patch)
tree032ecc9ad5bf24c2353fd1548743415d7178c0bd /test/ruby/test_fiber.rb
parentb3c264af015a9862ba8f9c0eedeb3495f5732f23 (diff)
downloadruby-6c33234d38ccf763537cd779c7af9eeaac7aa7fd.tar.gz
Fix Fiber with Thread issue on Windows [Bug #14642]
* cont.c (rb_threadptr_root_fiber_setup): divide into two functions: * rb_threadptr_root_fiber_setup_by_parent(): called by the parent thread. * rb_threadptr_root_fiber_setup_by_child(): called by the created thread. `rb_threadptr_root_fiber_setup()` is called by the parent thread and set fib->fib_handle by ConvertThreadToFiber() on the parent thread on Windows enveironment. This means that root_fib->fib_handle of child thread is initialized with parent thread's Fiber handle. Furthermore, second call of `ConvertThreadToFiber()` for the same thread fails. This patch solves this weird situateion. However, maybe we can make more clean code. * thread.c (thread_start_func_2): call `rb_threadptr_root_fiber_setup_by_child()` at thread initialize routine. * vm.c (th_init): call `rb_threadptr_root_fiber_setup_by_parent()`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@63073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_fiber.rb')
-rw-r--r--test/ruby/test_fiber.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_fiber.rb b/test/ruby/test_fiber.rb
index 7b513a11fa..6cb76d98d8 100644
--- a/test/ruby/test_fiber.rb
+++ b/test/ruby/test_fiber.rb
@@ -378,4 +378,13 @@ class TestFiber < Test::Unit::TestCase
assert_match(/terminated/, f.to_s)
assert_match(/resumed/, Fiber.current.to_s)
end
+
+ def assert_create_fiber_in_new_thread
+ ret = Thread.new{
+ Thread.new{
+ Fiber.new{Fiber.yield :ok}.resume
+ }.join
+ }.join
+ assert_euqal :ok, ret, '[Bug #14642]'
+ end
end