diff options
author | Alan Wu <XrXr@users.noreply.github.com> | 2023-04-14 15:04:55 -0400 |
---|---|---|
committer | Alan Wu <XrXr@users.noreply.github.com> | 2023-04-14 18:01:14 -0400 |
commit | 31e67a476f2262e01a0829e8ab5e6d8a97e0724e (patch) | |
tree | d377bc8b6ca4ba6f390bd6679408ebbfa173f914 /yjit | |
parent | 4501fb8b467cd40da5e160b82db7ea1a10d9e7ca (diff) | |
download | ruby-31e67a476f2262e01a0829e8ab5e6d8a97e0724e.tar.gz |
YJIT: Fix false object collection when setting ivar
Previously, setinstancevariable could generate code that calls
`rb_ensure_iv_list_size()` without first updating `cfp->sp`. This means
in the event that a GC start from within said routine the top few
objects would not be marked, causing them to be falsly collected.
Call `jit_prepare_routine_call()` first.
[Bug #19601]
Diffstat (limited to 'yjit')
-rw-r--r-- | yjit/src/codegen.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs index e135389ecf..e5437d707f 100644 --- a/yjit/src/codegen.rs +++ b/yjit/src/codegen.rs @@ -2290,6 +2290,11 @@ fn gen_setinstancevariable( if needs_extension { // Generate the C call so that runtime code will increase // the capacity and set the buffer. + asm.comment("call rb_ensure_iv_list_size"); + + // It allocates so can trigger GC, which takes the VM lock + // so could yield to a different ractor. + jit_prepare_routine_call(jit, asm); asm.spill_temps(); // for ccall asm.ccall(rb_ensure_iv_list_size as *const u8, vec![ |