diff options
author | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-03 10:21:47 +0000 |
---|---|---|
committer | ko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-04-03 10:21:47 +0000 |
commit | db3cc675f3c4e832028b67a202991fa78aa0a694 (patch) | |
tree | 032ecc9ad5bf24c2353fd1548743415d7178c0bd /thread.c | |
parent | c3da1625962acf32a47a4e12929fa9d45be9693e (diff) | |
download | ruby-db3cc675f3c4e832028b67a202991fa78aa0a694.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 'thread.c')
-rw-r--r-- | thread.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -643,6 +643,7 @@ thread_do_start(rb_thread_t *th, VALUE args) } void rb_ec_clear_current_thread_trace_func(const rb_execution_context_t *ec); +void rb_threadptr_root_fiber_setup_by_child(rb_thread_t *th); static int thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_start) @@ -662,6 +663,7 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s rb_bug("thread_start_func_2 must not be used for main thread"); ruby_thread_set_native(th); + rb_threadptr_root_fiber_setup_by_child(th); th->ec->machine.stack_start = stack_start; #ifdef __ia64 |