From 33edcc112081f96856d52e73253d73c97a5c4a3c Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Tue, 7 Mar 2023 13:10:07 -0800 Subject: [PATCH] YJIT: Protect strings from GC on String#<< (#7466) Fix https://github.com/Shopify/yjit/issues/310 [Bug #19483] Co-authored-by: Maxime Chevalier-Boisvert Co-authored-by: Jimmy Miller --- yjit/src/codegen.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs index 869c93fdbb..64f2d6e654 100644 --- a/yjit/src/codegen.rs +++ b/yjit/src/codegen.rs @@ -4288,6 +4288,9 @@ fn jit_rb_str_concat( // Guard that the argument is of class String at runtime. let arg_type = ctx.get_opnd_type(StackOpnd(0)); + // Guard buffers from GC since rb_str_buf_append may allocate. + gen_save_sp(asm, ctx); + let concat_arg = ctx.stack_pop(1); let recv = ctx.stack_pop(1);