10000 Initialize VM stack if VM_CHECK_MODE · k0kubun/ruby@def7023 · GitHub
[go: up one dir, main page]

Skip to content

Commit def7023

Browse files
committed
Initialize VM stack if VM_CHECK_MODE
Lately there has been a few flaky YJIT CI failures where a new Ruby thread is finding the canary on the VM stack. For example: https://github.com/ruby/ruby/actions/runs/8287357784/job/22679508482#step:14:109 After checking a local rr recording, it's clear that the canary was written there when YJIT was using a temporary malloc region, and then later handed to the new Ruby thread. Previously, the VM stack was uninitialized, so it can have stale values in it, like the canary. Though unlikely, this can happen without YJIT too. Initialize the stack if we're spawning canaries.
1 parent 185112f commit def7023

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

vm.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3560,6 +3560,10 @@ rb_ec_initialize_vm_stack(rb_execution_context_t *ec, VALUE *stack, size_t size)
35603560
{
35613561
rb_ec_set_vm_stack(ec, stack, size);
35623562

3563+
#if VM_CHECK_MODE > 0
3564+
MEMZERO(stack, VALUE, size); // malloc memory could have the VM canary in it
3565+
#endif
3566+
35633567
ec->cfp = (void *)(ec->vm_stack + ec->vm_stack_size);
35643568

35653569
vm_push_frame(ec,

0 commit comments

Comments
 (0)
0