Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 90 additions & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

Expand Down Expand Up @@ -127,11 +143,41 @@ Note: We're only listing outstanding class updates.
to make shareable Proc or lambda.
[[Feature #21550]], [[Feature #21557]]

* `Set`
* 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
`#<Set: {1, 2, 3}>`). 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.
Expand Down Expand Up @@ -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`:
Expand All @@ -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
Expand Down Expand Up @@ -283,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
Expand Down Expand Up @@ -320,17 +393,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
Expand All @@ -339,6 +421,10 @@ 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 #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
[Bug #21654]: https://bugs.ruby-lang.org/issues/21654
10 changes: 10 additions & 0 deletions bootstraptest/test_ractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions cont.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ractor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
57 changes: 57 additions & 0 deletions test/fiber/test_scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down