summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-08-02 00:50:42 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-08-02 00:50:42 +0000
commit92f7813ae27ca7037f9ab6e5744675c01b3fa574 (patch)
tree9c4b43d074f0ac3382e78c67628acbfd345ffd40 /thread.c
parentb7f205d54cd807419256ff829b416a8c2204aeec (diff)
release VM stack properly.
* cont.c: r55766 change the handling method of Fiber's VM stack. Resumed Fiber points NULL as VM stack and running Thread has responsibility to manage it (marking and releasing). However, thread_start_func_2()@thread.c and thread_free()@vm.c doesn't free the VM stack if corresponding root Fiber is exist. This causes memory leak. [Bug #13772] * cont.c (root_fiber_alloc): fib->cont.saved_thread.ec.stack should be NULL because running thread has responsibility to manage this stack. * vm.c (rb_thread_recycle_stack_release): assert given stack is not NULL (callers should care it). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/thread.c b/thread.c
index b7ee1d8d9b..0fa37b70f0 100644
--- a/thread.c
+++ b/thread.c
@@ -694,10 +694,8 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
rb_threadptr_unlock_all_locking_mutexes(th);
rb_check_deadlock(th->vm);
- if (!th->root_fiber) {
- rb_thread_recycle_stack_release(th->ec.stack);
- th->ec.stack = 0;
- }
+ rb_thread_recycle_stack_release(th->ec.stack);
+ th->ec.stack = NULL;
}
native_mutex_lock(&th->vm->thread_destruct_lock);
/* make sure vm->running_thread never point me after this point.*/