Commit graph

92413 commits

Author SHA1 Message Date
Yusuke Endoh
3546cedde3 Set up callable_method_entry for DUMMY frame on ArgumentError
Before the patch:
```
$ ./miniruby -e '[1, 2].inject(:tap)'
-e:1:in '<main>': wrong number of arguments (given 1, expected 0) (ArgumentError)
        from -e:1:in 'Enumerable#inject'
        from -e:1:in '<main>'
```

After the patch:
```
$ ./miniruby -e '[1, 2].inject(:tap)'
-e:1:in 'Kernel#tap': wrong number of arguments (given 1, expected 0) (ArgumentError)
        from -e:1:in 'Enumerable#inject'
        from -e:1:in '<main>'
```

Fixes https://bugs.ruby-lang.org/issues/20968#change-113811
2025-06-24 11:39:58 +09:00
Yusuke Endoh
a18fa86351 Change how to correct the first lineno in the backtrace on ArgumentError
Follow up to fix 3b7373fd00.
In that commit, the line number in the first frame was overwritten after
the whole backtrace was created. There was a problem that the line
number was overwritten even if the location was backpatched.

Instead, this commit uses first_lineno if the frame is
VM_FRAME_MAGIC_DUMMY when generating the backtrace.

Before the patch:
```
$ ./miniruby -e '[1, 2].inject(:tap)'
-e:in '<main>': wrong number of arguments (given 1, expected 0) (ArgumentError)
        from -e:1:in 'Enumerable#inject'
        from -e:1:in '<main>'
```

After the patch:
```
$ ./miniruby -e '[1, 2].inject(:tap)'
-e:1:in '<main>': wrong number of arguments (given 1, expected 0) (ArgumentError)
        from -e:1:in 'Enumerable#inject'
        from -e:1:in '<main>'
```
2025-06-24 11:39:58 +09:00
Max Bernstein
74e6bddf15
ZJIT: Parse putspecialobject(VMCore) into Const (#13683)
This way we get more information in HIR for the optimizer.

Fix https://github.com/Shopify/ruby/issues/587
2025-06-23 23:55:37 +00:00
Max Bernstein
3a9bf4a2ae
ZJIT: Optimize frozen array aref (#13666)
If we have a frozen array `[..., a, ...]` and a compile-time fixnum index `i`,
we can do the array load at compile-time.
2025-06-23 17:41:49 -05:00
tomoya ishida
67346a7d94
[Bug #21449] Fix Set#divide{|a,b|} using Union-find structure (#13680)
* [Bug #21449] Fix Set#divide{|a,b|} using Union-find structure

Implements Union-find structure with path compression.
Since divide{|a,b|} calls the given block n**2 times in the worst case, there is no need to implement union-by-rank or union-by-size optimization.

* Avoid internal arrays from being modified from block passed to Set#divide

Internal arrays can be modified from yielded block through ObjectSpace.
Freeze readonly array, use ALLOCV_N instead of mutable array.
2025-06-24 02:56:04 +09:00
BurdetteLamar
db6f397987 Tweaks for String#bytesize 2025-06-24 02:28:05 +09:00
ywenc
b1ce569ffc
ZJIT: anytostring to HIR (GH-13658)
Pop two values from the stack, return the first if it is a string,
otherwise return string coercion of the second

Also piggybacks a fix for string subclasses skipping `to_s` for
`objtostring`.

Co-authored-by: composerinteralia <composerinteralia@github.com>
2025-06-24 00:20:28 +09:00
Nobuyoshi Nakada
af6b98f7a2 Make the critical level an enum 2025-06-23 20:03:48 +09:00
Jean Boussier
c6dd07d66f Allocate singleton classes as namespaceable if their parent are 2025-06-23 10:04:58 +01:00
Jean Boussier
32ee3fab0a Shink RClass when it is known they can't be namespaced
Even when namespaces are enabled, only a few core classes created
during init will eventually be namespaced.

For these it's OK to allocate a 320B slot to hold the extra namespace
stuff.

But for any class created post init, we know we'll never need the
namespace and we can fit in a 160B slot.
2025-06-23 10:04:58 +01:00
Jean Boussier
ea4a53c595 Avoid creating namespace table for classes that can't be namespaced. 2025-06-23 10:04:58 +01:00
Jean Boussier
071b9affe6 Ensure RCLASS_CLASSEXT_TBL accessor is always used. 2025-06-23 10:04:58 +01:00
Jean Boussier
96a0c2065a Mark RClass instance that may be namespaced with RCLASS_NAMESPACEABLE 2025-06-23 10:04:58 +01:00
Jean Boussier
393e9a5f3e Optimize rb_namespace_available
Rather than to lazily check the env using a trinary
value, we can more straightforwardly check for the
env during the VM boot.

This allow `rb_namespace_available` to just be a pointer
dereference.
2025-06-23 10:04:58 +01:00
Nobuyoshi Nakada
ce38cba528
Merge blocks for the same condition 2025-06-23 11:08:22 +09:00
Nicholas La Roux
a1d62a3b1c [rubygems/rubygems] Handle RubyGems installing to custom dir with non-existent parent dirs
4701123601
2025-06-23 11:07:03 +09:00
David Rodríguez
8f009601f9 [rubygems/rubygems] Handle Errno::EADDRNOTAVAIL gracefully
As showed by the unskiped spec, on Windows trying to use the 0.0.0.0
interface raises this error, and it's raised as a generic system error
when trying to create a `bundler.lock` file. Here's is a better place to
handle that.

e32c5a9e5c
2025-06-23 11:07:02 +09:00
David Rodríguez
7fe1fc392e [rubygems/rubygems] Make HTTP_ERRORS list look like FAIL_ERRORS list
bfa6770e39
2025-06-23 11:07:01 +09:00
David Rodríguez
c3bfce512b [rubygems/rubygems] Simplify non retriable errors list
627a7615f2
2025-06-23 11:07:00 +09:00
David Rodríguez
627ca420e9 [rubygems/rubygems] Move HTTP_ERRORS together with the other error constants
57e8ae7aa6
2025-06-23 11:07:00 +09:00
David Rodríguez
746e0d3ef4 [rubygems/rubygems] Deprecate unused Bundler#SpecSet methods
380c95ce05
2025-06-23 11:06:59 +09:00
David Rodríguez
7c326ee72e [rubygems/rubygems] Remove usage of Bundler::SpecSet#<<
b556167793
2025-06-23 11:06:58 +09:00
David Rodríguez
7c115b8633 [rubygems/rubygems] Fix flaky test failures in mirror probing specs
The mirror probing spec file was moved to our regular suite, which runs
in parallel, recently. These specs rely on starting and stopping actual
servers in localhost, but this does not play nice with parallelization,
because a spec may kill the webserver another spec has created.

This commit moves mirror probing specs to not need to start servers in
localhost and do something more similar to what the other specs do.

ca9a19706f
2025-06-23 11:06:57 +09:00
Jeremy Evans
353fa6f0ba Avoid allocation for positional splat for literal array keyword argument
If all nodes in the array are safe, then it is safe to avoid
allocation for the positional splat:

```ruby
m(*a, kw: [:a])   # Safe
m(*a, kw: [meth]) # Unsafe
```

This avoids an unnecessary allocation in a Rails method call.
Details: https://github.com/rails/rails/pull/54949/files#r2052645431
2025-06-22 06:43:13 +09:00
Nobuyoshi Nakada
d84a811f31
[Bug #21448] Reorder trials in fill_random_bytes
First try dedicated system calls, such as `getrandom` or `getentropy`,
next possible libraries, then fallback to `/dev/urandom`.
2025-06-22 02:00:56 +09:00
Nobuyoshi Nakada
ec20f7feb6
Suppress warnings
- `ractor_sync_terminate_atfork` is unused unless fork is working
- `cr` in `vm_lock_leave` is only for debugging
2025-06-22 01:08:38 +09:00
Jean Boussier
edbd9ed468 variable.c: avoid out of bound write in generic_field_set
[Bug #21445]
2025-06-21 14:40:40 +01:00
Kazuki Yamaguchi
0cec4a14fb Restore getrandom(2) path for Linux with glibc 2.36 or later
This is a follow-up to commit b120f5e38d (avoid fork-unsafe arc4random
implementations, 2018-09-04).

Avoid defining a no-op fill_random_bytes_syscall() if arc4random_buf(3)
exists, but we are unsure if it is fork-safe. Check for other options
instead. IOW, see if getrandom(2) is available.

glibc 2.36, released in 2022, started to provide arc4random_buf(3) on
Linux. This causes fill_random_bytes_syscall() to use neither of them
and makes Random.urandom solely rely on getentropy(3) via
fill_random_bytes_urandom().

While the glibc implementation is safe, I did not add it to the list
because using getrandom(2) directly is preferable on Linux.
2025-06-21 19:57:19 +09:00
Nobuyoshi Nakada
1181a682a6
[Bug #21448] Use getentropy(2) only on macOS
If this is not a system call, then it is using getrandom (which would
have been tried already), and cannot be used as a replacement for the
random devices.
2025-06-21 16:52:16 +09:00
Nobuyoshi Nakada
dbc596938a
Move a comment to the corresponding conditional block [ci skip] 2025-06-21 13:14:42 +09:00
Max Bernstein
6602a08aa5
ZJIT: Move ccall comments near ccall instructions (#13662)
Don't confuse them with other nearby instructions.
2025-06-21 09:15:05 +09:00
Jeremy Evans
1d94a9e1a4 Fix handling of PM_CONSTANT_PATH_NODE node in keyword arguments with ARGS_SPLAT
This was handled correctly in parse.y (NODE_COLON2), but not in
prism. This wasn't caught earlier, because I only added tests for
the optimized case and not the unoptimized case. Add tests for
the unoptimized case.

In code terms:

```ruby
m(*a, kw: lvar::X)     # Does not require allocation for *a
m(*a, kw: method()::X) # Requires allocation for *a
```

This commit fixes the second case when prism is used.
2025-06-21 08:46:24 +09:00
Kazuki Yamaguchi
112ba70647 [ruby/openssl] ssl: add SSLContext#sigalgs= and #client_sigalgs=
Add methods for setting supported signature algorithms, corresponding
to SSL_CTX_set1_sigalgs_list() and SSL_CTX_set1_client_sigalgs_list(),
respectively.

6bbe58c492

Co-authored-by: Markus Jung <markus.jung@vivavis.com>
2025-06-20 17:58:38 +00:00
Kazuki Yamaguchi
0d75dd1f47 [ruby/openssl] ssl: update rdoc for SSLContext#ciphers= and #ciphersuites=
54f22395e7
2025-06-20 17:58:38 +00:00
Kazuki Yamaguchi
444b94c087 [ruby/openssl] ssl: correct array index type in build_cipher_string()
9c9333c07d
2025-06-20 17:58:37 +00:00
Hiroshi SHIBATA
b6babd9a07
ZJIT: Typofix (#13665) 2025-06-20 09:52:45 -07:00
Nobuyoshi Nakada
d31d62d685
Dump with debugger just once 2025-06-20 20:35:50 +09:00
Nobuyoshi Nakada
d9efc56c16 [ruby/io-console] Ignore ^C at interrupt
It's something we don't expect and might be coming from somewhere
else.

f0646b2b6a
2025-06-20 09:39:29 +00:00
Hiroshi SHIBATA
7addde1ece Revert to setup-ruby v1.231.0
v1.245.0 is not working with the following issue:

4446417911

```
D:/a/ruby/ruby/src/test/rubygems/mock_gem_ui.rb:83:in 'Gem::MockGemUi#terminate_interaction': Gem::MockGemUi::TermError (Gem::MockGemUi::TermError)
  	D:/a/ruby/ruby/src/lib/rubygems/user_interaction.rb:157:in 'Gem::UserInteraction#terminate_interaction'
  	D:/a/ruby/ruby/src/lib/rubygems/commands/exec_command.rb:175:in 'Gem::Commands::ExecCommand#install'
  	D:/a/ruby/ruby/src/lib/rubygems/commands/exec_command.rb:70:in 'Gem::Commands::ExecCommand#execute'
  	D:/a/ruby/ruby/src/lib/rubygems/command.rb:326:in 'Gem::Command#invoke_with_build_args'
  	D:/a/ruby/ruby/src/lib/rubygems/command.rb:304:in 'Gem::Command#invoke'
  	D:/a/ruby/ruby/src/test/rubygems/test_gem_commands_exec_command.rb:43:in 'TestGemCommandsExecCommand#invoke'
  	D:/a/ruby/ruby/src/test/rubygems/test_gem_commands_exec_command.rb:274:in 'block in TestGemCommandsExecCommand#test_gem_with_platform_and_platform_dependencies'
  	D:/a/ruby/ruby/src/lib/rubygems/user_interaction.rb:46:in 'Gem::DefaultUserInteraction.use_ui'
  	D:/a/ruby/ruby/src/lib/rubygems/user_interaction.rb:69:in 'Gem::DefaultUserInteraction#use_ui'
  	D:/a/ruby/ruby/src/test/rubygems/test_gem_commands_exec_command.rb:272:in 'TestGemCommandsExecCommand#test_gem_with_platform_and_platform_dependencies'
  	D:/a/ruby/ruby/src/tool/lib/test/unit/testcase.rb:202:in 'Test::Unit::TestCase#run_test'
  	D:/a/ruby/ruby/src/tool/lib/test/unit/testcase.rb:170:in 'Test::Unit::TestCase#run'
  	D:/a/ruby/ruby/src/tool/lib/test/unit.rb:1683:in 'block in Test::Unit::Runner#_run_suite'
  	D:/a/ruby/ruby/src/tool/lib/test/unit.rb:1670:in 'Array#map'
  	D:/a/ruby/ruby/src/tool/lib/test/unit.rb:1670:in 'Test::Unit::Runner#_run_suite'
  	D:/a/ruby/ruby/src/tool/lib/test/unit.rb:1374:in 'Test::Unit::ExcludesOption#_run_suite'
  	D:/a/ruby/ruby/src/tool/lib/test/unit/parallel.rb:52:in 'Test::Unit::Worker#_run_suite'
  	D:/a/ruby/ruby/src/tool/lib/test/unit/parallel.rb:24:in 'block in Test::Unit::Worker#_run_suites'
  	D:/a/ruby/ruby/src/tool/lib/test/unit/parallel.rb:23:in 'Array#map'
  	D:/a/ruby/ruby/src/tool/lib/test/unit/parallel.rb:23:in 'Test::Unit::Worker#_run_suites'
  	D:/a/ruby/ruby/src/tool/lib/test/unit/parallel.rb:122:in 'Test::Unit::Worker#run'
  	D:/a/ruby/ruby/src/tool/lib/test/unit/parallel.rb:220:in '<main>'
  running file: D:/a/ruby/ruby/src/test/rubygems/test_gem_commands_exec_command.rb
```
2025-06-20 17:55:48 +09:00
Hiroshi SHIBATA
092ea7a163 Update to the latest step versions at the GitHub Actions 2025-06-20 17:55:48 +09:00
Nobuyoshi Nakada
896f9f6328 CI: Run Launchable in the build directory
As well as compilers/entrypoint.sh.
2025-06-20 17:40:59 +09:00
Nobuyoshi Nakada
7a735c4861
Fix indents in macros 2025-06-20 16:50:03 +09:00
Nobuyoshi Nakada
68d6cc6bd7
Do not fetch already fetched commits 2025-06-20 16:50:03 +09:00
Hiroshi SHIBATA
29c7f849db
Use another credential for generating new releases 2025-06-20 15:33:47 +09:00
git
8ce6546371 Update bundled gems list as of 2025-06-20 2025-06-20 04:52:53 +00:00
Hiroshi SHIBATA
e23941677c
Rename token name to more descriptive 2025-06-20 12:45:54 +09:00
Hiroshi SHIBATA
1e428366ae Use windows-2025 image because that have pre-installed winget 2025-06-20 12:35:16 +09:00
Hiroshi SHIBATA
fafae10d9a
Separate credential with auto_request_review and others 2025-06-20 11:40:05 +09:00
Hiroshi SHIBATA
9e8fa9bcd7
Re-enabled to upload sarif file of scorecards 2025-06-20 10:44:31 +09:00
Hiroshi SHIBATA
5468148581
Update scorecards action with the latest template file 2025-06-20 10:44:03 +09:00