From 13689c269970f18316952541f8544830ec2dc5c4 Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Sun, 8 Mar 2026 09:43:26 +0100 Subject: [PATCH 1/2] Add missing GC_GUARD in `fbuffer_append_str` Ref: fff25c9f4b9c590a59ed4a2ec3c545121db844d3 `StringValuePtr` use `volatile` so the compiler is less likely to re-use the register. But regardless, we should GC_GUARD `str` as we no longer reference it after `GETMEM`. --- ext/json/ext/fbuffer/fbuffer.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ext/json/ext/fbuffer/fbuffer.h b/ext/json/ext/fbuffer/fbuffer.h index d5fd5ea2..9660e70d 100644 --- a/ext/json/ext/fbuffer/fbuffer.h +++ b/ext/json/ext/fbuffer/fbuffer.h @@ -166,6 +166,7 @@ static void fbuffer_append_str(FBuffer *fb, VALUE str) RSTRING_GETMEM(str, ptr, len); fbuffer_append(fb, ptr, len); + RB_GC_GUARD(str); } static void fbuffer_append_str_repeat(FBuffer *fb, VALUE str, size_t repeat) @@ -182,6 +183,7 @@ static void fbuffer_append_str_repeat(FBuffer *fb, VALUE str, size_t repeat) fbuffer_append_reserved(fb, ptr, len); repeat--; } + RB_GC_GUARD(str); } static inline void fbuffer_append_char(FBuffer *fb, char newchr) From 4a42a04280d96d8dd94558078c16f1c078c38e1b Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Sun, 8 Mar 2026 10:13:53 +0100 Subject: [PATCH 2/2] Release 2.19.1 --- CHANGES.md | 4 ++++ lib/json/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index a66b4d45..3638ab3e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,10 @@ ### Unreleased +### 2026-03-08 (2.19.1) + +* Fix a compiler dependent GC bug introduced in `2.18.0`. + ### 2026-03-06 (2.19.0) * Fix `allow_blank` parsing option to no longer allow invalid types (e.g. `load([], allow_blank: true)` now raise a type error). diff --git a/lib/json/version.rb b/lib/json/version.rb index 3f73c0d9..aa56d3a4 100644 --- a/lib/json/version.rb +++ b/lib/json/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module JSON - VERSION = '2.19.0' + VERSION = '2.19.1' end