From 02cddcc2be3150fad1da37ebdeb6e2d9ec29306c Mon Sep 17 00:00:00 2001 From: Koichi Sasada Date: Fri, 5 Dec 2025 02:48:05 +0900 Subject: [PATCH 1/5] Ractor.shareable_proc(&pr) should copy pr `pr` should not change on this method. --- bootstraptest/test_ractor.rb | 10 ++++++++++ ractor.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/bootstraptest/test_ractor.rb b/bootstraptest/test_ractor.rb index 7d09ac52838f66..bec742da4be0d5 100644 --- a/bootstraptest/test_ractor.rb +++ b/bootstraptest/test_ractor.rb @@ -157,6 +157,16 @@ Ractor.shareable_proc(&closure).call } +# Ractor.make_shareable makes a copy of given Proc +assert_equal '[true, true]', %q{ + pr1 = Proc.new do + self + end + pr2 = Ractor.shareable_proc(&pr1) + + [pr1.call == self, pr2.call == nil] +} + # Ractor::IsolationError cases assert_equal '3', %q{ ok = 0 diff --git a/ractor.c b/ractor.c index b7c7d9467924b6..9fec70a1dfab71 100644 --- a/ractor.c +++ b/ractor.c @@ -2376,7 +2376,7 @@ ractor_shareable_proc(rb_execution_context_t *ec, VALUE replace_self, bool is_la } else { VALUE proc = is_lambda ? rb_block_lambda() : rb_block_proc(); - return rb_proc_ractor_make_shareable(proc, replace_self); + return rb_proc_ractor_make_shareable(rb_proc_dup(proc), replace_self); } } From d3a9a17b6f908a64d8cf7b35c5e7337be3fc7cc5 Mon Sep 17 00:00:00 2001 From: Hiroshi SHIBATA Date: Fri, 5 Dec 2025 11:00:17 +0900 Subject: [PATCH 2/5] Skip Windows runner group warning under ruby/ruby repo --- spec/bundler/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/bundler/spec_helper.rb b/spec/bundler/spec_helper.rb index fad1d4ce3266d4..a79e33fbb01684 100644 --- a/spec/bundler/spec_helper.rb +++ b/spec/bundler/spec_helper.rb @@ -145,5 +145,5 @@ def self.ruby=(ruby) if metadata[:type] != :aruba && metadata.keys.none? {|k| Spec::WindowsTagGroup::EXAMPLE_MAPPINGS.keys.include?(k) } warn "#{metadata[:file_path]} is not assigned to any Windows runner group. see spec/support/windows_tag_group.rb for details." end - end + end unless Spec::Path.ruby_core? end From e822209d3e3dfde39a7d6818951869606ae8cbf0 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Fri, 5 Dec 2025 14:16:25 +0900 Subject: [PATCH 3/5] Update NEWS.md for Ruby 4.0.0 (#15369) I extracted the relevant descriptions from the draft NEWS.md that hsbt-san had Gemini generate by analyzing `git log`. Co-authored-by: Hiroshi SHIBATA Co-authored-by: Alan Wu Co-authored-by: Jeremy Evans Co-Authored-By: Earlopain <14981592+Earlopain@users.noreply.github.com> --- NEWS.md | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 74 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 89f45deb99cf7b..84f8eaaaac2116 100644 --- a/NEWS.md +++ b/NEWS.md @@ -64,6 +64,12 @@ Note: We're only listing outstanding class updates. Also, `Binding#local_variable_get` and `Binding#local_variable_set` reject to handle numbered parameters. [[Bug #21049]] +* File + + * `File::Stat#birthtime` is now available on Linux via the statx + system call when supported by the kernel and filesystem. + [[Feature #21205]] + * IO * `IO.select` accepts `Float::INFINITY` as a timeout argument. @@ -76,10 +82,20 @@ Note: We're only listing outstanding class updates. * `Math.log1p` and `Math.expm1` are added. [[Feature #21527]] -* Socket +* Method - * `Socket.tcp` & `TCPSocket.new` accepts `open_timeout` as a keyword argument to specify - the timeout for the initial connection. [[Feature #21347]] + * `Method#source_location`, `Proc#source_location`, and + `UnboundMethod#source_location` now return extended location + information with 5 elements: `[path, start_line, start_column, + end_line, end_column]`. The previous 2-element format `[path, + line]` can still be obtained by calling `.take(2)` on the result. + [[Feature #6012]] + +* Proc + + * `Proc#parameters` now shows anonymous optional parameters as `[:opt]` + instead of `[:opt, nil]`, making the output consistent with when the + anonymous parameter is required. [[Bug #20974]] * Ractor @@ -127,11 +143,41 @@ Note: We're only listing outstanding class updates. to make shareable Proc or lambda. [[Feature #21550]], [[Feature #21557]] +* Range + + * `Range#to_set` and `Enumerator#to_set` now perform size checks to prevent + issues with endless ranges. [[Bug #21654]] + + * `Range#overlap?` now correctly handles infinite (unbounded) ranges. + [[Bug #21185]] + + * `Range#max` behavior on beginless integer ranges has been fixed. + [[Bug #21174]] [[Bug #21175]] + +* Ruby + + * A new toplevel module `Ruby` has been defined, which contains + Ruby-related constants. This module was reserved in Ruby 3.4 + and is now officially defined. [[Feature #20884]] + * `Set` * `Set` is now a core class, instead of an autoloaded stdlib class. [[Feature #21216]] + * `Set#inspect` now returns a string suitable for `eval`, using the + `Set[]` syntax (e.g., `Set[1, 2, 3]` instead of + `#`). This makes it consistent with other core + collection classes like Array and Hash. [[Feature #21389]] + + * Passing arguments to `Set#to_set` and `Enumerable#to_set` is now deprecated. + [[Feature #21390]] + +* Socket + + * `Socket.tcp` & `TCPSocket.new` accepts an `open_timeout` keyword argument to specify + the timeout for the initial connection. [[Feature #21347]] + * String * Update Unicode to Version 17.0.0 and Emoji Version 17.0. @@ -240,6 +286,11 @@ The following bundled gems are updated. ## Supported platforms +* Windows + + * Dropped support for MSVC versions older than 14.0 (_MSC_VER 1900). + This means Visual Studio 2015 or later is now required. + ## Compatibility issues * The following methods were removed from Ractor due to the addition of `Ractor::Port`: @@ -253,6 +304,14 @@ The following bundled gems are updated. * `ObjectSpace._id2ref` is deprecated. [[Feature #15408]] +* `Process::Status#&` and `Process::Status#>>` have been removed. + They were deprecated in Ruby 3.3. [[Bug #19868]] + +* `rb_path_check` has been removed. This function was used for + `$SAFE` path checking which was removed in Ruby 2.7, + and was already deprecated,. + [[Feature #20971]] + ## Stdlib compatibility issues * CGI library is removed from the default gems. Now we only provide `cgi/escape` for @@ -320,17 +379,26 @@ A lot of work has gone into making Ractors more stable, performant, and usable. * `--rjit` is removed. We will move the implementation of the third-party JIT API to the [ruby/rjit](https://github.com/ruby/rjit) repository. +[Feature #6012]: https://bugs.ruby-lang.org/issues/6012 [Feature #15408]: https://bugs.ruby-lang.org/issues/15408 [Feature #17473]: https://bugs.ruby-lang.org/issues/17473 [Feature #18455]: https://bugs.ruby-lang.org/issues/18455 [Feature #19630]: https://bugs.ruby-lang.org/issues/19630 +[Bug #19868]: https://bugs.ruby-lang.org/issues/19868 [Feature #19908]: https://bugs.ruby-lang.org/issues/19908 [Feature #20610]: https://bugs.ruby-lang.org/issues/20610 [Feature #20724]: https://bugs.ruby-lang.org/issues/20724 +[Feature #20884]: https://bugs.ruby-lang.org/issues/20884 [Feature #20925]: https://bugs.ruby-lang.org/issues/20925 +[Feature #20971]: https://bugs.ruby-lang.org/issues/20971 +[Bug #20974]: https://bugs.ruby-lang.org/issues/20974 [Feature #21047]: https://bugs.ruby-lang.org/issues/21047 [Bug #21049]: https://bugs.ruby-lang.org/issues/21049 [Feature #21166]: https://bugs.ruby-lang.org/issues/21166 +[Bug #21174]: https://bugs.ruby-lang.org/issues/21174 +[Bug #21175]: https://bugs.ruby-lang.org/issues/21175 +[Bug #21185]: https://bugs.ruby-lang.org/issues/21185 +[Feature #21205]: https://bugs.ruby-lang.org/issues/21205 [Feature #21216]: https://bugs.ruby-lang.org/issues/21216 [Feature #21219]: https://bugs.ruby-lang.org/issues/21219 [Feature #21258]: https://bugs.ruby-lang.org/issues/21258 @@ -339,6 +407,9 @@ A lot of work has gone into making Ractors more stable, performant, and usable. [Feature #21287]: https://bugs.ruby-lang.org/issues/21287 [Feature #21347]: https://bugs.ruby-lang.org/issues/21347 [Feature #21360]: https://bugs.ruby-lang.org/issues/21360 +[Feature #21389]: https://bugs.ruby-lang.org/issues/21389 +[Feature #21390]: https://bugs.ruby-lang.org/issues/21390 [Feature #21527]: https://bugs.ruby-lang.org/issues/21527 [Feature #21550]: https://bugs.ruby-lang.org/issues/21550 [Feature #21557]: https://bugs.ruby-lang.org/issues/21557 +[Bug #21654]: https://bugs.ruby-lang.org/issues/21654 From 5f6b31c23ff1eefdf3cd5807ce5f80abf24eb1b2 Mon Sep 17 00:00:00 2001 From: Sharon Rosner Date: Fri, 5 Dec 2025 06:20:39 +0100 Subject: [PATCH 4/5] Correctly handle `Process.fork` with an active `Fiber.scheduler`. (#15385) In the child process, nullify the current fiber scheduler and set the current fiber to blocking. --- cont.c | 2 ++ test/fiber/test_scheduler.rb | 57 ++++++++++++++++++++++++++++++++++++ thread.c | 1 + 3 files changed, 60 insertions(+) diff --git a/cont.c b/cont.c index 50e8ffb3498ec4..acfcefc81e89f2 100644 --- a/cont.c +++ b/cont.c @@ -3371,6 +3371,8 @@ rb_fiber_atfork(rb_thread_t *th) th->root_fiber = th->ec->fiber_ptr; } th->root_fiber->prev = 0; + th->root_fiber->blocking = 1; + th->blocking = 1; } } #endif diff --git a/test/fiber/test_scheduler.rb b/test/fiber/test_scheduler.rb index 7c77bd8cf0dba4..97ce94bd270b69 100644 --- a/test/fiber/test_scheduler.rb +++ b/test/fiber/test_scheduler.rb @@ -226,4 +226,61 @@ def test_condition_variable thread.join assert_kind_of RuntimeError, error end + + def test_post_fork_scheduler_reset + omit 'fork not supported' unless Process.respond_to?(:fork) + + forked_scheduler_state = nil + thread = Thread.new do + r, w = IO.pipe + scheduler = Scheduler.new + Fiber.set_scheduler scheduler + + forked_pid = fork do + r.close + w << (Fiber.scheduler ? 'set' : 'reset') + w.close + end + w.close + forked_scheduler_state = r.read + Process.wait(forked_pid) + ensure + r.close rescue nil + w.close rescue nil + end + thread.join + assert_equal 'reset', forked_scheduler_state + ensure + thread.kill rescue nil + end + + def test_post_fork_fiber_blocking + omit 'fork not supported' unless Process.respond_to?(:fork) + + fiber_blocking_state = nil + thread = Thread.new do + r, w = IO.pipe + scheduler = Scheduler.new + Fiber.set_scheduler scheduler + + forked_pid = nil + Fiber.schedule do + forked_pid = fork do + r.close + w << (Fiber.current.blocking? ? 'blocking' : 'nonblocking') + w.close + end + end + w.close + fiber_blocking_state = r.read + Process.wait(forked_pid) + ensure + r.close rescue nil + w.close rescue nil + end + thread.join + assert_equal 'blocking', fiber_blocking_state + ensure + thread.kill rescue nil + end end diff --git a/thread.c b/thread.c index 6e5c8e89ff075a..5f592a42562adf 100644 --- a/thread.c +++ b/thread.c @@ -4997,6 +4997,7 @@ rb_thread_atfork(void) rb_threadptr_pending_interrupt_clear(th); rb_thread_atfork_internal(th, terminate_atfork_i); th->join_list = NULL; + th->scheduler = Qnil; rb_fiber_atfork(th); /* We don't want reproduce CVE-2003-0900. */ From 479185daa140f9d5894e9c254f2f881d36df1ddc Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Thu, 4 Dec 2025 21:52:55 -0800 Subject: [PATCH 5/5] Add Set C API to news Also, don't use backticks around Set in the top level of the Core classes updates section, as other classes/modules do not use that format. --- NEWS.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index 84f8eaaaac2116..53ed47cb8c3265 100644 --- a/NEWS.md +++ b/NEWS.md @@ -160,7 +160,7 @@ Note: We're only listing outstanding class updates. Ruby-related constants. This module was reserved in Ruby 3.4 and is now officially defined. [[Feature #20884]] -* `Set` +* Set * `Set` is now a core class, instead of an autoloaded stdlib class. [[Feature #21216]] @@ -342,6 +342,20 @@ The following bundled gems are updated. `IO` objects share the same file descriptor, closing one does not affect the other. [[Feature #18455]] +* Set + + * A C API for `Set` has been added. The following methods are supported: + [[Feature #21459]] + + * `rb_set_foreach` + * `rb_set_new` + * `rb_set_new_capa` + * `rb_set_lookup` + * `rb_set_add` + * `rb_set_clear` + * `rb_set_delete` + * `rb_set_size` + ## Implementation improvements ### Ractor @@ -409,6 +423,7 @@ A lot of work has gone into making Ractors more stable, performant, and usable. [Feature #21360]: https://bugs.ruby-lang.org/issues/21360 [Feature #21389]: https://bugs.ruby-lang.org/issues/21389 [Feature #21390]: https://bugs.ruby-lang.org/issues/21390 +[Feature #21459]: https://bugs.ruby-lang.org/issues/21459 [Feature #21527]: https://bugs.ruby-lang.org/issues/21527 [Feature #21550]: https://bugs.ruby-lang.org/issues/21550 [Feature #21557]: https://bugs.ruby-lang.org/issues/21557