Skip to content

Commit

Permalink
YJIT: Fix kwrest calls setting SP with uninit values
Browse files Browse the repository at this point in the history
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
  • Loading branch information
XrXr committed Feb 12, 2024
1 parent 0536b2c commit cbdabd5
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions yjit/src/codegen.rs
Expand Up @@ -6996,13 +6996,8 @@ fn gen_send_iseq(

let mut unspecified_bits = 0;

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

// Build the keyword rest parameter hash before we make any changes to the order of
// the supplied keyword arguments
Expand Down Expand Up @@ -7089,6 +7084,14 @@ fn gen_send_iseq(
}
}

// Ensure the stack is large enough for the callee
for _ in caller_keyword_len..callee_kw_count {
argc += 1;
asm.stack_push(Type::Unknown);
}
// Now this is the stack_opnd() index to the 0th keyword argument.
let kwargs_stack_base = kwargs_order.len() as i32 - 1;

// Next, we're going to loop through every keyword that was
// specified by the caller and make sure that it's in the correct
// place. If it's not we're going to swap it around with another one.
Expand Down

0 comments on commit cbdabd5

Please sign in to comment.