aboutsummaryrefslogtreecommitdiffstats
path: root/thread.c
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2019-06-05 13:53:19 +1200
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2019-06-19 20:39:10 +1200
commit7c7a1c221281cdba1f48d5e42ee2f9af306d27f8 (patch)
treef8d557230a7828a2ec6be9636c76def38a0a51f6 /thread.c
parentb24603adff8ec1e93e71358b93b3e30c99ba29d5 (diff)
downloadruby-7c7a1c221281cdba1f48d5e42ee2f9af306d27f8.tar.gz
Fix handling of vm_stack_size and avoid trying to deallocate it.
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/thread.c b/thread.c
index 81018b9721..477e96e3b4 100644
--- a/thread.c
+++ b/thread.c
@@ -714,22 +714,25 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_s
rb_thread_list_t *join_list;
rb_thread_t *main_th;
VALUE errinfo = Qnil;
- size_t vm_stack_size = th->vm->default_params.thread_vm_stack_size;
if (th == th->vm->main_thread) {
rb_bug("thread_start_func_2 must not be used for main thread");
}
- rb_ec_set_vm_stack(th->ec, alloca(vm_stack_size), vm_stack_size / sizeof(VALUE));
- th->ec->cfp = (void *)(th->ec->vm_stack + th->ec->vm_stack_size);
+ {
+ size_t size = th->vm->default_params.thread_vm_stack_size / sizeof(VALUE);
+ rb_ec_set_vm_stack(th->ec, alloca(size * sizeof(VALUE)), size);
+
+ th->ec->cfp = (void *)(th->ec->vm_stack + th->ec->vm_stack_size);
- rb_vm_push_frame(th->ec,
- 0 /* dummy iseq */,
- VM_FRAME_MAGIC_DUMMY | VM_ENV_FLAG_LOCAL | VM_FRAME_FLAG_FINISH | VM_FRAME_FLAG_CFRAME /* dummy frame */,
- Qnil /* dummy self */, VM_BLOCK_HANDLER_NONE /* dummy block ptr */,
- 0 /* dummy cref/me */,
- 0 /* dummy pc */, th->ec->vm_stack, 0, 0
- );
+ rb_vm_push_frame(th->ec,
+ 0 /* dummy iseq */,
+ VM_FRAME_MAGIC_DUMMY | VM_ENV_FLAG_LOCAL | VM_FRAME_FLAG_FINISH | VM_FRAME_FLAG_CFRAME /* dummy frame */,
+ Qnil /* dummy self */, VM_BLOCK_HANDLER_NONE /* dummy block ptr */,
+ 0 /* dummy cref/me */,
+ 0 /* dummy pc */, th->ec->vm_stack, 0, 0
+ );
+ }
ruby_thread_set_native(th);
@@ -817,7 +820,7 @@ 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);
- rb_fiber_close(th->ec->fiber_ptr);
+ // rb_fiber_close(th->ec->fiber_ptr);
}
thread_cleanup_func(th, FALSE);
gvl_release(th->vm);