Commit graph

92432 commits

Author SHA1 Message Date
Jean Boussier
5bcc639b34 Disallow forking from non-main ractor
[Bug #17516]

`fork(2)` only leave the calling thread alive in the child.
Because of this forking from the non-main ractor can easily
leave the VM in a corrupted state.

It may be possible in the future to carefully allow forking from non-main
Ractor, but shot term it's preferable to add this restriction.
2025-06-24 15:10:40 +01:00
Jean Boussier
45a2c95d0f Reduce exposure of FL_FREEZE
The `FL_FREEZE` flag is redundant with `SHAPE_ID_FL_FROZEN`, so
ideally it should be eliminated in favor of the later.

Doing so would eliminate the risk of desync between the two, but
also solve the problem of the frozen status being global in namespace
context (See Bug #21330).
2025-06-24 11:29:39 +01:00
Nobuyoshi Nakada
da10b956e0
Generate HTML documentation even if only NEWS.md is updated 2025-06-24 18:50:50 +09:00
git
cf6b4e7278 Update default gems list at 62aa4a6010 [ci skip] 2025-06-24 09:33:51 +00:00
Hiroshi SHIBATA
62aa4a6010 [ruby/resolv] v0.6.1
6b57765f8d
2025-06-24 09:32:57 +00:00
Nobuyoshi Nakada
152cf102b7
Remove trailing spaces 2025-06-24 18:30:54 +09:00
Hiroshi SHIBATA
21f3ffedd4
tmpdir.rb is not extension 2025-06-24 18:26:38 +09:00
Nobuyoshi Nakada
ac02bf2b72 [ruby/json] Remove trailing spaces [ci skip]
6c41162522
2025-06-24 18:19:04 +09:00
Samuel Williams
ba68343d3a
Allow wakeup mutex to be used in trap context. (#13684) 2025-06-24 05:55:07 +00:00
Hiroshi SHIBATA
e036d4da8d
Removed Set entry
Fixup 061d36476f
2025-06-24 13:40:54 +09:00
Hiroshi SHIBATA
7a5e46cff2
Revert accidentally commit with 96a0c2065a 2025-06-24 12:10:50 +09:00
Jean Boussier
93fc29c65c
[ruby/json] Deprecate duplicate keys in object
There are few legitimate use cases for duplicate keys, and can
in some case be exploited.

Rather to always silently accept them, we should emit a warning,
and in the future require to explictly allow them.

06f00a42e8
2025-06-24 12:10:50 +09:00
Jean Boussier
b310e7b3c7
[ruby/json] Add missing parser options documentation
eed753ffde
2025-06-24 12:10:50 +09:00
David Rodríguez
7a297ad2f9
[rubygems/rubygems] Fix Bundler.original_env['GEM_HOME'] when Bundler is trampolined
4c450eb05e
2025-06-24 12:10:50 +09:00
David Rodríguez
bc6b045153
[rubygems/rubygems] Cleanup now unnecessary RUBYOPT handling
ac83c78635
2025-06-24 12:10:50 +09:00
David Rodríguez
32a9f29cc8
[rubygems/rubygems] Remove no longer necessary workarounds for restarts
Since we no longer pass ruby CLI flags in our spec commands, we no
longer need the previous workaround and can get the realworld code
tested.

fd92c855fb
2025-06-24 12:10:50 +09:00
David Rodríguez
6217216be2
[rubygems/rubygems] Use ENV consistently over CLI flags for specs
dafe50f171
2025-06-24 12:10:50 +09:00
David Rodríguez
0a8ed97b32
[rubygems/rubygems] Helper for hax file
8b7ddf8a07
2025-06-24 12:10:50 +09:00
David Rodríguez
c115e3d974
[rubygems/rubygems] bundle exec does not need artifice in general
cb1f19573a
2025-06-24 12:10:50 +09:00
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