aboutsummaryrefslogtreecommitdiffstats
path: root/thread.c
diff options
context:
space:
mode:
authorSamuel Williams <samuel.williams@oriontransfer.co.nz>2019-06-20 11:32:08 +1200
committerSamuel Williams <samuel.williams@oriontransfer.co.nz>2019-06-20 11:32:08 +1200
commit25049a6e818d879aecb88379753f1e215b915f93 (patch)
tree901466f729232e4c116b62ef6a866f53e837dd70 /thread.c
parent91c4ef01512d1ba285ccb3c3cb03e611257790e8 (diff)
downloadruby-25049a6e818d879aecb88379753f1e215b915f93.tar.gz
Extra assertions around thread.
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/thread.c b/thread.c
index 7cb8062075..8d4a671453 100644
--- a/thread.c
+++ b/thread.c
@@ -713,19 +713,19 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start)
rb_bug("thread_start_func_2 must not be used for main thread");
}
+ thread_debug("thread start: %p\n", (void *)th);
+ VM_ASSERT((size * sizeof(VALUE)) <= th->ec->machine.stack_maxsize);
+
vm_stack = alloca(size * sizeof(VALUE));
VM_ASSERT(vm_stack);
gvl_acquire(th->vm, th);
rb_ec_initialize_vm_stack(th->ec, vm_stack, size);
-
- ruby_thread_set_native(th);
-
th->ec->machine.stack_start = STACK_DIR_UPPER(vm_stack + size, vm_stack);
th->ec->machine.stack_maxsize -= size * sizeof(VALUE);
- thread_debug("thread start: %p\n", (void *)th);
+ ruby_thread_set_native(th);
{
thread_debug("thread start (get lock): %p\n", (void *)th);
@@ -806,7 +806,11 @@ thread_start_func_2(rb_thread_t *th, VALUE *stack_start)
rb_fiber_close(th->ec->fiber_ptr);
}
+
thread_cleanup_func(th, FALSE);
+ VM_ASSERT(this->ec->vm_stack == NULL);
+ VM_ASSERT(this->ec->cfp == NULL);
+
gvl_release(th->vm);
return 0;
@@ -2253,6 +2257,7 @@ rb_threadptr_execute_interrupts(rb_thread_t *th, int blocking_timing)
if (th->status == THREAD_RUNNABLE)
th->running_time_us += TIME_QUANTUM_USEC;
+ VM_ASSERT(th->ec->cfp);
EXEC_EVENT_HOOK(th->ec, RUBY_INTERNAL_EVENT_SWITCH, th->ec->cfp->self,
0, 0, 0, Qundef);