diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2019-06-20 11:31:22 +1200 |
---|---|---|
committer | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2019-06-20 16:44:50 +1200 |
commit | e4cafa393f8fd4aa207f20b1d122884b4de99cf1 (patch) | |
tree | 78e6a286bcb55b6dd180153b1be9508090c25090 /cont.c | |
parent | c26c51449461e3c8ee9bb4e1800933fb3d3caf67 (diff) |
Ensure that vm_stack is cleared in `thread_cleanup_func_before_exec`.
If `vm_stack` is left dangling in a forked process, the gc attempts to scan
it, but it is invalid and will cause a segfault. Therefore, we clear it
before forking.
In order to simplify this, `rb_ec_clear_vm_stack` was introduced.
Diffstat (limited to 'cont.c')
-rw-r--r-- | cont.c | 11 |
1 files changed, 2 insertions, 9 deletions
@@ -268,13 +268,6 @@ fiber_status_set(rb_fiber_t *fib, enum fiber_status s) fib->status = s; } -void -rb_ec_set_vm_stack(rb_execution_context_t *ec, VALUE *stack, size_t size) -{ - ec->vm_stack = stack; - ec->vm_stack_size = size; -} - static inline void ec_switch(rb_thread_t *th, rb_fiber_t *fib) { @@ -705,7 +698,7 @@ cont_capture(volatile int *volatile stat) cont->saved_vm_stack.ptr = ALLOC_N(VALUE, ec->vm_stack_size); MEMCPY(cont->saved_vm_stack.ptr, ec->vm_stack, VALUE, ec->vm_stack_size); #endif - rb_ec_set_vm_stack(&cont->saved_ec, NULL, 0); + rb_ec_clear_vm_stack(&cont->saved_ec); cont_save_machine_stack(th, cont); /* backup ensure_list to array for search in another context */ @@ -1793,7 +1786,7 @@ rb_fiber_close(rb_fiber_t *fib) } } - rb_ec_set_vm_stack(ec, NULL, 0); + rb_ec_clear_vm_stack(ec); #if !FIBER_USE_NATIVE /* should not mark machine stack any more */ |