Skip to content

Commit cbdabd5

Browse files
committed
YJIT: Fix kwrest calls setting SP with uninit values
We did stack_push() and then saved the SP without writing to the slots of the new values first, which caused the GC to mark uninitialized values. Should fix crashes like https://github.com/ruby/ruby/actions/runs/7877298133/job/21493179294
1 parent 0536b2c commit cbdabd5

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

yjit/src/codegen.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6996,13 +6996,8 @@ fn gen_send_iseq(
69966996

69976997
let mut unspecified_bits = 0;
69986998

6999-
// Start by ensuring the stack is large enough for the callee
7000-
for _ in caller_keyword_len..callee_kw_count {
7001-
argc += 1;
7002-
asm.stack_push(Type::Unknown);
7003-
}
7004-
// Now this is the stack_opnd() index to the 0th keyword argument.
7005-
let kwargs_stack_base = kwargs_order.len() as i32 - 1;
6999+
// The stack_opnd() index to the 0th keyword argument.
7000+
let kwargs_stack_base = caller_keyword_len_i32 - 1;
70067001

70077002
// Build the keyword rest parameter hash before we make any changes to the order of
70087003
// the supplied keyword arguments
@@ -7089,6 +7084,14 @@ fn gen_send_iseq(
70897084
}
70907085
}
70917086

7087+
// Ensure the stack is large enough for the callee
7088+
for _ in caller_keyword_len..callee_kw_count {
7089+
argc += 1;
7090+
asm.stack_push(Type::Unknown);
7091+
}
7092+
// Now this is the stack_opnd() index to the 0th keyword argument.
7093+
let kwargs_stack_base = kwargs_order.len() as i32 - 1;
7094+
70927095
// Next, we're going to loop through every keyword that was
70937096
// specified by the caller and make sure that it's in the correct
70947097
// place. If it's not we're going to swap it around with another one.

0 commit comments

Comments
 (0)