summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/vm.c b/vm.c
index 6f20d43ee4..a8822239cf 100644
--- a/vm.c
+++ b/vm.c
@@ -2982,6 +2982,7 @@ rb_vm_update_references(void *ptr)
if (ptr) {
rb_vm_t *vm = ptr;
+ vm->self = rb_gc_location(vm->self);
vm->mark_object_ary = rb_gc_location(vm->mark_object_ary);
vm->load_path = rb_gc_location(vm->load_path);
vm->load_path_snapshot = rb_gc_location(vm->load_path_snapshot);
@@ -3068,6 +3069,8 @@ rb_vm_mark(void *ptr)
rb_gc_mark_maybe(*list->varptr);
}
+ rb_gc_mark_movable(vm->self);
+
if (vm->main_namespace) {
rb_namespace_entry_mark((void *)vm->main_namespace);
}
@@ -3672,10 +3675,10 @@ rb_ec_initialize_vm_stack(rb_execution_context_t *ec, VALUE *stack, size_t size)
void
rb_ec_clear_vm_stack(rb_execution_context_t *ec)
{
- rb_ec_set_vm_stack(ec, NULL, 0);
-
- // Avoid dangling pointers:
+ // set cfp to NULL before clearing the stack in case `thread_profile_frames`
+ // gets called in this middle of `rb_ec_set_vm_stack` via signal handler.
ec->cfp = NULL;
+ rb_ec_set_vm_stack(ec, NULL, 0);
}
static void