From 8351378bf3173d48fd8510badf1139809553185a Mon Sep 17 00:00:00 2001 From: Samuel Williams Date: Sun, 10 May 2026 16:58:45 +0900 Subject: [PATCH 1/5] `rb_fiber_scheduler_blocking_operation_wait` can garbage collect `blocking_operation` incorrectly. (#16908) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Place RB_GC_GUARD(blocking_operation) after the last implicit use of the VALUE — all accesses via the derived `operation` pointer — so the compiler cannot treat blocking_operation as dead before this point, keeping it reachable as a GC root through rb_funcall and through all subsequent uses of the raw pointer. --- scheduler.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scheduler.c b/scheduler.c index c2f370a22aee4e..3205bb3bc9a7c3 100644 --- a/scheduler.c +++ b/scheduler.c @@ -1111,6 +1111,9 @@ VALUE rb_fiber_scheduler_blocking_operation_wait(VALUE scheduler, void* (*functi operation->data2 = NULL; operation->unblock_function = NULL; + // Ensure that the blocking operation remains visible until this point: + RB_GC_GUARD(blocking_operation); + // If the blocking operation was never executed, return Qundef to signal the caller to use rb_nogvl instead if (current_status == RB_FIBER_SCHEDULER_BLOCKING_OPERATION_STATUS_QUEUED) { return Qundef; From 78562d38fb9e8079d6e810dc16c3594dc4515932 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 10 May 2026 19:54:36 +0900 Subject: [PATCH 2/5] mingw: Include stdio.h for `__MINGW_PRINTF_FORMAT` This macro is not pre-defined but defined in stdio.h. --- include/ruby/internal/attr/format.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/ruby/internal/attr/format.h b/include/ruby/internal/attr/format.h index b3488ee00a36aa..7feff1c84637ff 100644 --- a/include/ruby/internal/attr/format.h +++ b/include/ruby/internal/attr/format.h @@ -22,6 +22,10 @@ */ #include "ruby/internal/has/attribute.h" +#if defined(__MINGW32__) +#include /* for __MINGW_PRINTF_FORMAT */ +#endif + /** Wraps (or simulates) `__attribute__((format))` */ #if RBIMPL_HAS_ATTRIBUTE(format) # define RBIMPL_ATTR_FORMAT(x, y, z) __attribute__((__format__(x, y, z))) From 186da0b481333354bc97534396fb91e222989dc9 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Sun, 10 May 2026 19:56:16 +0900 Subject: [PATCH 3/5] Fix modifier for `size_t` --- shape.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shape.c b/shape.c index 2b4256e5f3068c..24f1394f6cd32f 100644 --- a/shape.c +++ b/shape.c @@ -1529,7 +1529,7 @@ Init_default_shapes(void) } if (heaps_count > SHAPE_ID_HEAP_INDEX_MAX) { - rb_bug("Init_default_shapes initialized with %lu heaps, only up to %u are supported", heaps_count, SHAPE_ID_HEAP_INDEX_MAX); + rb_bug("Init_default_shapes initialized with %zu heaps, only up to %u are supported", heaps_count, SHAPE_ID_HEAP_INDEX_MAX); } size_t index; From a41ae11d98e39eb4b3576576a2acc775998a6a8b Mon Sep 17 00:00:00 2001 From: dak2 Date: Sun, 10 May 2026 21:24:30 +0900 Subject: [PATCH 4/5] [DOC] Remove unnecessary backticks from ZJIT docs The Markdown formatting was broken, so I removed it. --- doc/jit/zjit.md | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/jit/zjit.md b/doc/jit/zjit.md index 2b8bd640f1fca0..ebe5cc4f9bb7b3 100644 --- a/doc/jit/zjit.md +++ b/doc/jit/zjit.md @@ -365,7 +365,6 @@ Note that this disables profiling. To inject interpreter profiles into ZJIT, con ```bash ./miniruby --zjit --zjit-dump-hir -e "30.times { 1 + 1 }" ``` -``` ### Viewing HIR in Iongraph From a9102cc3fe4c92297009b2041661d6abe5c2179e Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Sun, 10 May 2026 10:11:35 -0400 Subject: [PATCH 5/5] Remove rb_gc_worker_thread_(un)set_vm_context These functions are no longer used. --- gc.c | 30 ------------------------------ gc/gc.h | 2 -- 2 files changed, 32 deletions(-) diff --git a/gc.c b/gc.c index 1d3f6fa6ed15be..e0757a20dd48f4 100644 --- a/gc.c +++ b/gc.c @@ -198,36 +198,6 @@ rb_gc_initialize_vm_context(struct rb_gc_vm_context *context) context->ec = GET_EC(); } -#if USE_MODULAR_GC -void -rb_gc_worker_thread_set_vm_context(struct rb_gc_vm_context *context) -{ - rb_native_mutex_lock(&context->lock); - - GC_ASSERT(rb_current_execution_context(false) == NULL); - -#ifdef RB_THREAD_LOCAL_SPECIFIER - rb_current_ec_set(context->ec); -#else - native_tls_set(ruby_current_ec_key, context->ec); -#endif -} - -void -rb_gc_worker_thread_unset_vm_context(struct rb_gc_vm_context *context) -{ - rb_native_mutex_unlock(&context->lock); - - GC_ASSERT(rb_current_execution_context(true) == context->ec); - -#ifdef RB_THREAD_LOCAL_SPECIFIER - rb_current_ec_set(NULL); -#else - native_tls_set(ruby_current_ec_key, NULL); -#endif -} -#endif - bool rb_gc_event_hook_required_p(rb_event_flag_t event) { diff --git a/gc/gc.h b/gc/gc.h index 31ce736778d295..2809c7a128b824 100644 --- a/gc/gc.h +++ b/gc/gc.h @@ -101,8 +101,6 @@ MODULAR_GC_FN bool rb_gc_obj_needs_cleanup_p(VALUE obj); MODULAR_GC_FN bool rb_gc_event_hook_required_p(rb_event_flag_t event); MODULAR_GC_FN void *rb_gc_get_ractor_newobj_cache(void); MODULAR_GC_FN void rb_gc_initialize_vm_context(struct rb_gc_vm_context *context); -MODULAR_GC_FN void rb_gc_worker_thread_set_vm_context(struct rb_gc_vm_context *context); -MODULAR_GC_FN void rb_gc_worker_thread_unset_vm_context(struct rb_gc_vm_context *context); MODULAR_GC_FN void rb_gc_move_obj_during_marking(VALUE from, VALUE to); MODULAR_GC_FN void rb_gc_print_backtrace(); #endif