96113 Commits

Author SHA1 Message Date
Luke Gruber
4fb537b1ee
Make tracepoints with set_trace_func or TracePoint.new ractor local (#15468)
Before this change, GC'ing any Ractor object caused you to lose all
enabled tracepoints across all ractors (even main). Now tracepoints are
ractor-local and this doesn't happen. Internal events are still global.

Fixes [Bug #19112]
2025-12-16 14:06:55 -05:00
Alan Wu
d209e6f1c0 search_nonascii(): Replace UB pointer cast with memcpy
Casting a pointer to create an unaligned one is undefined behavior in C
standards. Use memcpy to express the unaligned load instead to play by
the rules.

Practically, this yields the same binary output in many situations
while fixing the crash in [Bug #21715].
2025-12-16 13:06:03 -05:00
Aaron Patterson
a8ba2b295b add 21254 to the feature list 2025-12-16 09:44:44 -08:00
Étienne Barrié
aab4f6287d
Add the instance variable name and the module in Ractor::IsolationError (#15563) 2025-12-16 11:47:13 -05:00
Étienne Barrié
09a29e1312
Add the class variable and the class itself in Ractor::IsolationError (#15562) 2025-12-16 11:06:33 -05:00
Satoshi Tagomori
6b35f074bd Box: [DOC] Add RUBY_BOX in Environment 2025-12-16 22:23:24 +09:00
Misaki Shioi
2b1a9afbfb
Fix: Do not pass negative timeout to Addrinfo#connect_internal (#15578)
This change fixes a bug where, with `Socket.tcp`’s `fast_fallback option` disabled, specifying `open_timeout` could unintentionally pass a negative value to `Addrinfo#connect_internal`, `causing an ArgumentError`.

```
❯ ruby -rsocket -e 'p Socket.tcp("localhost", 9292, open_timeout: 1, fast_fallback: false)'
/Users/misaki-shioi/src/install/lib/ruby/4.0.0+0/socket.rb:64:in 'IO#wait_writable': time interval must not be negative (ArgumentError)

          sock.wait_writable(timeout) or
                             ^^^^^^^
	from /Users/misaki-shioi/src/install/lib/ruby/4.0.0+0/socket.rb:64:in 'Addrinfo#connect_internal'
	from /Users/misaki-shioi/src/install/lib/ruby/4.0.0+0/socket.rb:141:in 'Addrinfo#connect'
	from /Users/misaki-shioi/src/install/lib/ruby/4.0.0+0/socket.rb:964:in 'block in Socket.tcp_without_fast_fallback'
	from /Users/misaki-shioi/src/install/lib/ruby/4.0.0+0/socket.rb:231:in 'Array#each'
	from /Users/misaki-shioi/src/install/lib/ruby/4.0.0+0/socket.rb:231:in 'Addrinfo.foreach'
	from /Users/misaki-shioi/src/install/lib/ruby/4.0.0+0/socket.rb:945:in 'Socket.tcp_without_fast_fallback'
	from /Users/misaki-shioi/src/install/lib/ruby/4.0.0+0/socket.rb:671:in 'Socket.tcp'
	from -e:1:in '<main>'
```
2025-12-16 19:52:45 +09:00
Jean Boussier
e42bcd7ce7 Rename fiber_serial into ec_serial
Since it now live in the EC.
2025-12-16 09:51:07 +01:00
Jean Boussier
28b195fc67 Store the fiber_serial in the EC to allow inlining
Mutexes spend a significant amount of time in `rb_fiber_serial`
because it can't be inlined (except with LTO).
The fiber struct is opaque the so function can't be defined as inlineable.

Ideally the while fiber struct would not be opaque to the rest of
Ruby core, but it's tricky to do.

Instead we can store the fiber serial in the execution context
itself, and make its access cheaper:

```
$ hyperfine './miniruby-baseline --yjit /tmp/mut.rb' './miniruby-inline-serial --yjit /tmp/mut.rb'
Benchmark 1: ./miniruby-baseline --yjit /tmp/mut.rb
  Time (mean ± σ):      4.011 s ±  0.084 s    [User: 3.977 s, System: 0.011 s]
  Range (min … max):    3.950 s …  4.245 s    10 runs

Benchmark 2: ./miniruby-inline-serial --yjit /tmp/mut.rb
  Time (mean ± σ):      3.495 s ±  0.150 s    [User: 3.448 s, System: 0.009 s]
  Range (min … max):    3.340 s …  3.869 s    10 runs

Summary
  ./miniruby-inline-serial --yjit /tmp/mut.rb ran
    1.15 ± 0.05 times faster than ./miniruby-baseline --yjit /tmp/mut.rb
```

```ruby
i = 10_000_000
mut = Mutex.new
while i > 0
  i -= 1
  mut.synchronize { }
  mut.synchronize { }
  mut.synchronize { }
  mut.synchronize { }
  mut.synchronize { }
  mut.synchronize { }
  mut.synchronize { }
  mut.synchronize { }
  mut.synchronize { }
  mut.synchronize { }
end
```
2025-12-16 09:51:07 +01:00
Nobuyoshi Nakada
85b40c5ea8 Box: fix the class name in tests 2025-12-16 16:53:13 +09:00
Nobuyoshi Nakada
5f09e1f046 Box: [DOC] fix the class name in rdoc
Also remove a stale TODO.
2025-12-16 16:53:13 +09:00
Nobuyoshi Nakada
8db3642ab5 Box: fix the class name in inspect 2025-12-16 16:53:13 +09:00
Nobuyoshi Nakada
7780d3b6c3 Box: fix the environment variable name 2025-12-16 16:53:13 +09:00
Nobuyoshi Nakada
f4c48505ca Box: move extensions from namespace to box 2025-12-16 16:53:13 +09:00
Nobuyoshi Nakada
065c48cdf1 Revert "[Feature #6012] Extend source_location for end position
and columns"

This reverts commit 073c4e1cc712064e626914fa4a5a8061f903a637.

https://bugs.ruby-lang.org/issues/6012#note-31
> we will cancel this feature in 4.0 because of design ambiguities
> such as whether to return column positions in bytes or characters as
> in [#21783].

[#21783]: https://bugs.ruby-lang.org/issues/21783
2025-12-16 16:13:07 +09:00
Hiroshi SHIBATA
5b0fefef41 [ruby/rubygems] Added assertion for Windows and nmake
https://github.com/ruby/rubygems/commit/be5c4e27d9
2025-12-16 06:28:36 +00:00
Hiroshi SHIBATA
e4797e9321 [ruby/rubygems] Reset MAKEFLAGS option for build jobs tests
https://github.com/ruby/rubygems/commit/09e6031a11
2025-12-16 05:18:29 +00:00
Edouard CHIN
080bf30c48 [ruby/rubygems] Allow to specify the number of make jobs when installing gems:
- Added a new `-j` option to `gem install` and `gem update`.
  This option allows to specify the number of jobs we pass to `make`
  when compiling gem with native extensions.

  By default its the number of processors, but users may want a way
  to control this.

  You can use it like so: `gem install json -j8`

https://github.com/ruby/rubygems/commit/67aad88ca6
2025-12-16 04:21:49 +00:00
Edouard CHIN
9f593156b6 [ruby/rubygems] Pass down value of BUNDLE_JOBS to RubyGems before compiling:
- ### Problem

  Since https://github.com/ruby/rubygems/pull/9131, we are now
  compiling make rules simultaneously. The number of jobs
  is equal to the number of processors.
  This may be problematic for some users as they want to control
  this value.

  ### Solution

  The number of jobs passed to `make` will now be equal to the
  `BUNDLE_JOBS` value.

  ### Side note

  It's also worth to note that since Bundler installs gems in
  parallel, we may end up running multiple `make -j<JOB>` in parallel
  which would cause exhaust the number of processors we have.
  This problem can be fixed by implementing a GNU jobserver, which I
  plan to do. But I felt that this would be too much change in one PR.

https://github.com/ruby/rubygems/commit/d51995deb9
2025-12-16 04:21:49 +00:00
Randy Stauner
9168cad4d6 YJIT: Bail out if proc would be stored above stack top
Fixes [Bug #21266].
2025-12-15 23:05:27 -05:00
hituzi no sippo
f3b9509b52 [ruby/rubygems] Fix quote handling in mise format ruby version parsing
The previous regex didn't properly match quoted strings
it would capture the opening quote as part of the version
if quotes were mismatched.
This change properly parses double-quoted, single-quoted,
and unquoted version strings separately.

https://github.com/ruby/rubygems/commit/81e48c8185
2025-12-16 03:56:22 +00:00
hituzi no sippo
3b50f4ba41 [ruby/rubygems] Support single quotes in mise format ruby version
https://github.com/ruby/rubygems/commit/a7d7ab39dd
2025-12-16 03:56:21 +00:00
Alan Wu
3b3ab33851 ZJIT: Fix test failures from line number of Primitive shifting
This can happen with documentation updates and we don't want
those to trip on ZJIT tests.

Redact the whole name since names like "_bi342" aren't that helpful
anyways.
2025-12-15 22:18:44 -05:00
Hiroshi SHIBATA
060199910a [ruby/rubygems] Allow to show cli_help with bundler executable
https://github.com/ruby/rubygems/commit/a091e3fd10
2025-12-16 02:36:10 +00:00
dependabot[bot]
38d67986b0 Bump actions/cache in /.github/actions/setup/directories
Bumps [actions/cache](https://github.com/actions/cache) from 5.0.0 to 5.0.1.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](a783357455...9255dc7a25)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: 5.0.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-12-15 16:56:19 -08:00
Peter Zhu
b6d4562e6a [DOC] Remove copyright from Set class docs 2025-12-15 19:25:15 -05:00
Edouard CHIN
ff1b8ffa61 [ruby/rubygems] Tweak the Bundler's "X gems now installed message":
- Fix https://github.com/ruby/rubygems/pull/9188
- This message is a bit misleading because it always outputs one extra
  specs, which is Bundler itself.

  This is now fixed when the message is about to be output.

https://github.com/ruby/rubygems/commit/70b4e19506
2025-12-16 00:16:15 +00:00
Edouard CHIN
f88e797090 [ruby/rubygems] Allow bundle pristine to work for git gems in the same repo:
- Fix https://github.com/ruby/rubygems/pull/9186
- ### Problem

  Running `bundle pristine` in a Gemfile where there is many git gem
  pointing to the same repository will result in a error
  "Another git process seems to be running in this repository".

  ### Context

  This error is a regression since https://github.com/ruby/rubygems/commit/a555fd6ccd17
  where `bundle pristine` now runs in parallel which could lead
  to running simultaneous git operations in the same repository.

  ### Solution

  When Bundler pristine a git gem it does a `git reset --hard` without
  specifying a path.
  This means the whole repository will be reset. In this case, we can
  leverage that by just pristining one gem per unique git sources.
  This is also more efficient.

https://github.com/ruby/rubygems/commit/710ba514a8
2025-12-16 00:15:57 +00:00
Max Bernstein
98cac1a75d
Point people to redmine on ZJIT docs (#15499)
Fix https://github.com/Shopify/ruby/issues/900
2025-12-15 19:10:04 -05:00
Benoit Daloze
abefd3e8ff [ruby/psych] Check that Data members match exactly
* Fixes https://github.com/ruby/psych/issues/760

https://github.com/ruby/psych/commit/952008c898
2025-12-15 22:48:40 +00:00
nick evans
b3f0fb5618 [ruby/psych] Replace C extension with Data#initialize bind_call
https://github.com/ruby/psych/commit/6a826693ba
2025-12-15 22:48:40 +00:00
BurdetteLamar
cfd41cbf03 [DOC] Harmonize #-@ methods 2025-12-15 17:28:35 -05:00
BurdetteLamar
acbf55f4e6 [DOC] Harmonize #- methods 2025-12-15 17:27:54 -05:00
BurdetteLamar
7fbf321d23 [DOC] Harmonize #** methods 2025-12-15 17:27:24 -05:00
Luke Gruber
98ab418fed
Revert "Fix Socket.tcp cleanup after Thread#kill (#15131)" (#15565)
This reverts commit 3038286a4bf7832f1c42c8cc9774ee6ff19876fc.

The following CI failure scared me:
https://github.com/ruby/ruby/actions/runs/20241051861/job/58108997049

```
  1) Timeout:
  TestResolvDNS#test_multiple_servers_with_timeout_and_truncated_tcp_fallback
```

Since it could be related, I'm reverting this for now.
2025-12-15 17:07:15 -05:00
git
74b24e09d4 Update default gems list at adf676c530b5da2822aa3b03ee43e5 [ci skip] 2025-12-15 17:16:21 +00:00
Takashi Kokubun
adf676c530 [ruby/erb] Version 6.0.1
https://github.com/ruby/erb/commit/bbde68fcd5
2025-12-15 17:15:25 +00:00
Daisuke Aritomo
fdd8bdea81 [ruby/erb] Freeze ERB::Compiler::TrimScanner::ERB_STAG
(https://github.com/ruby/erb/pull/100)

For Ractor compatibility.

https://github.com/ruby/erb/commit/43f0876595
2025-12-15 17:14:36 +00:00
Max Bernstein
9581d6c898
ZJIT: Add iongraph-generating Ruby script (#15466)
Run like so:

    $ ../tool/zjit_iongraph.rb ../build-dev/miniruby --zjit-call-threshold=2 tmp/ghbug.rb
    false
    false
    tmp/ghbug.rb:3:in 'Object#doit': this shouldnt ever be nil (RuntimeError)
            from tmp/ghbug.rb:10:in '<main>'
    W, [2025-12-09T11:00:32.070382 #67400]  WARN -- : Command failed with exit status 1
    zjit_iongraph_67405.html
    $

Then open zjit_iongraph_67405.html with your browser.
2025-12-15 16:52:35 +00:00
Luke Gruber
3038286a4b
Fix Socket.tcp cleanup after Thread#kill (#15131)
Socket.tcp launches ruby threads to resolve hostnames, and those threads
communicate through a queue implemented with `IO.pipe`. When the thread
that called `Socket.tcp` is killed, the resolver threads still try to
communicate through the pipe even though it may be closed. The method
`Socket.tcp_with_fast_fallback` tries to deal with this by killing the
threads in an ensure block, and then closing the pipe. However, calling
`Thread#kill` is not a blocking operation, it only sets a flag on the
thread telling it to raise during the next interrupt. The thread needs
to be joined to ensure it is terminated. The following script
demonstrates the issue:

```ruby
require "socket"

ts = []
5.times do
  ts << Thread.new do
    loop do
      1_000.times do |i|
        puts "#{i}"
        t = Thread.new do
          Socket.tcp("ruby-lang.org", 80)
        end
        sleep 0.001
        t.kill
      end
    end
  end
end
ts.each(&:join)
```

output:
```
/Users/luke/workspace/ruby-dev/ruby-build-debug/.ext/common/socket.rb:1019:in 'IO#write': closed stream (IOError)
	from /Users/luke/workspace/ruby-dev/ruby-build-debug/.ext/common/socket.rb:1019:in 'IO#putc'
	from /Users/luke/workspace/ruby-dev/ruby-build-debug/.ext/common/socket.rb:1019:in 'block in Socket::HostnameResolutionResult#add'
	from /Users/luke/workspace/ruby-dev/ruby-build-debug/.ext/common/socket.rb:1017:in 'Thread::Mutex#synchronize'
	from /Users/luke/workspace/ruby-dev/ruby-build-debug/.ext/common/socket.rb:1017:in 'Socket::HostnameResolutionResult#add'
	from /Users/luke/workspace/ruby-dev/ruby-build-debug/.ext/common/socket.rb:980:in 'Socket.resolve_hostname'
	from /Users/luke/workspace/ruby-dev/ruby-build-debug/.ext/common/socket.rb:719:in 'block (2 levels) in Socket.tcp_with_fast_fallback'
/Users/luke/workspace/ruby-dev/ruby-build-debug/.ext/common/socket.rb:1019:in 'IO#write': closed stream (IOError)
	from /Users/luke/workspace/ruby-dev/ruby-build-debug/.ext/common/socket.rb:1019:in 'IO#putc'
	from /Users/luke/workspace/ruby-dev/ruby-build-debug/.ext/common/socket.rb:1019:in 'block in Socket::HostnameResolutionResult#add'
	from /Users/luke/workspace/ruby-dev/ruby-build-debug/.ext/common/socket.rb:1017:in 'Thread::Mutex#synchronize'
	from /Users/luke/workspace/ruby-dev/ruby-build-debug/.ext/common/socket.rb:1017:in 'Socket::HostnameResolutionResult#add'
	from /Users/luke/workspace/ruby-dev/ruby-build-debug/.ext/common/socket.rb:978:in 'Socket.resolve_hostname'
	from /Users/luke/workspace/ruby-dev/ruby-build-debug/.ext/common/socket.rb:719:in 'block (2 levels) in Socket.tcp_with_fast_fallback'
```
2025-12-15 11:48:34 -05:00
Jeremy Evans
6b63b0cbeb [DOC] Update Set#inspect description in NEWS 2025-12-16 01:28:11 +09:00
Étienne Barrié
bb0e42c5e7 Define Array#detect as an alias for Array#find
Otherwise Array#detect is Enumerable#detect while Array#find uses a
different more performant implementation.

[Feature #21678]
2025-12-15 10:52:43 -05:00
Kevin Newton
ac946e076c [ruby/prism] Unreference before destroying in call node in pattern
https://github.com/ruby/prism/commit/609c80c91e
2025-12-15 13:43:53 +00:00
Kevin Newton
eceab2f44c [ruby/prism] Escape error location is incorrect for some regex
When you have a regular expression that has a named capture that
has an escape sequence in the named capture, and that escape
sequence is a unicode escape sequence with an invalid surrogate
pair, the error was attached to the owned string as opposed to a
location on the shared source.

https://github.com/ruby/prism/commit/793a7a6a0a
2025-12-15 11:38:29 +00:00
Benoit Daloze
bbc10ed0cd Add NEWS entry for Array#rfind and Array#find 2025-12-15 12:11:46 +01:00
git
35209caef2 Update default gems list at f0793731853c0e130f798e9dc5c736 [ci skip] 2025-12-15 09:51:22 +00:00
Kazuki Yamaguchi
f079373185 [ruby/openssl] Ruby/OpenSSL 4.0.0
https://github.com/ruby/openssl/commit/5af1edab18
2025-12-15 09:50:30 +00:00
Kazuki Yamaguchi
f06eb75646 [ruby/openssl] ossl.c: improve docs for constants and methods under ::OpenSSL
https://github.com/ruby/openssl/commit/b0de8ba9bd
2025-12-15 09:09:49 +00:00
Kazuki Yamaguchi
ee6ba41bfd [ruby/openssl] Freeze more constants for Ractor compatibility
https://github.com/ruby/openssl/commit/695126f582
2025-12-15 09:09:49 +00:00
Nobuyoshi Nakada
5a4faaaeb1 Merge root_box_data into root_box
* Make invariant `root_box` an array consist of only `root_box_data`.
* Remove the unnecessary initializer list that is just overwritten in
  `initialize_root_box()` and missing `classext_cow_classes`.
* Shrink the scope using another local `root_box`.
* Make the data type constants static.
2025-12-15 16:05:21 +09:00