From e949242dce04de0b320862923184ccc6ad8b3861 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 31 Aug 2021 16:58:29 -0700 Subject: [PATCH] Guard array when appending This prevents early collection of the array. The GC doesn't see the array on the stack when Ruby is compiled with optimizations enabled [ruby-core:105099] [Bug #18140] --- array.c | 1 + 1 file changed, 1 insertion(+) diff --git a/array.c b/array.c index 34fdc7b22a..50a61db876 100644 --- a/array.c +++ b/array.c @@ -4845,6 +4845,7 @@ ary_append(VALUE x, VALUE y) if (n > 0) { rb_ary_splice(x, RARRAY_LEN(x), 0, RARRAY_CONST_PTR_TRANSIENT(y), n); } + RB_GC_GUARD(y); return x; } -- 2.30.2