From 05917fd1e6d8539db013b087d4ea93cf068038e1 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 9 Oct 2026 21:20:36 +0900 Subject: [PATCH] Return rb_len_t from rb_RSTRING_LEN unsigned long can be narrower than rb_len_t, which would truncate the length that YJIT and ZJIT read through this function. https://bugs.ruby-lang.org/issues/22400 Co-Authored-By: Claude Opus 5.5 --- jit.c | 2 +- yjit/src/cruby_bindings.inc.rs | 2 +- zjit/src/cruby_bindings.inc.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jit.c b/jit.c index 7c3646fa97f..eb42aa88d02 100644 --- a/jit.c +++ b/jit.c @@ -108,7 +108,7 @@ rb_iseq_bare_opcode_at_pc(const rb_iseq_t *iseq, const VALUE *pc) return rb_vm_insn_addr2insn((const void *)at_pc); } -unsigned long +rb_len_t rb_RSTRING_LEN(VALUE str) { return RSTRING_LEN(str); diff --git a/yjit/src/cruby_bindings.inc.rs b/yjit/src/cruby_bindings.inc.rs index d5d6ce369ab..be6cac37f4f 100644 --- a/yjit/src/cruby_bindings.inc.rs +++ b/yjit/src/cruby_bindings.inc.rs @@ -1303,7 +1303,7 @@ extern "C" { pub fn rb_iseq_encoded_size(iseq: *const rb_iseq_t) -> ::std::os::raw::c_uint; pub fn rb_iseq_pc_at_idx(iseq: *const rb_iseq_t, insn_idx: u32) -> *mut VALUE; pub fn rb_iseq_opcode_at_pc(iseq: *const rb_iseq_t, pc: *const VALUE) -> ::std::os::raw::c_int; - pub fn rb_RSTRING_LEN(str_: VALUE) -> ::std::os::raw::c_ulong; + pub fn rb_RSTRING_LEN(str_: VALUE) -> rb_len_t; pub fn rb_RSTRING_PTR(str_: VALUE) -> *mut ::std::os::raw::c_char; pub fn rb_insn_name(insn: VALUE) -> *const ::std::os::raw::c_char; pub fn rb_vm_ci_argc(ci: *const rb_callinfo) -> ::std::os::raw::c_uint; diff --git a/zjit/src/cruby_bindings.inc.rs b/zjit/src/cruby_bindings.inc.rs index 4e130bd9830..02745e7139d 100644 --- a/zjit/src/cruby_bindings.inc.rs +++ b/zjit/src/cruby_bindings.inc.rs @@ -2505,7 +2505,7 @@ unsafe extern "C" { iseq: *const rb_iseq_t, pc: *const VALUE, ) -> ::std::os::raw::c_int; - pub fn rb_RSTRING_LEN(str_: VALUE) -> ::std::os::raw::c_ulong; + pub fn rb_RSTRING_LEN(str_: VALUE) -> rb_len_t; pub fn rb_RSTRING_PTR(str_: VALUE) -> *mut ::std::os::raw::c_char; pub fn rb_insn_name(insn: VALUE) -> *const ::std::os::raw::c_char; pub fn rb_vm_ci_argc(ci: *const rb_callinfo) -> ::std::os::raw::c_uint;