96158 Commits

Author SHA1 Message Date
Luke Gruber
56b67f1684
ObjectSpace.{dump,dump_all,dump_shapes} needs vm barrier. (#15569)
This allows these methods to be called from ractors.

Add new exported function `rb_vm_lock_with_barrier()` that requires
users to include "vm_sync.h"
2025-12-17 12:17:30 -05:00
Misaki Shioi
41e24aeb1a
Improve NEWS.md for Socket (#15610) 2025-12-17 22:06:53 +09:00
Yusuke Endoh
aee4b24829 [ruby/error_highlight] Show no message when failing to get caller/callee snippets
Even with Ruby 4.0, snippets is not always available, such as in irb by
default. It would be better to just say nothing than to show a confusing
message.

https://github.com/ruby/error_highlight/commit/ef80ce73a1
2025-12-17 21:11:27 +09:00
Akinori Musha
c99670d668 Revert the default size of Enumerator::Producer to infinity
[Bug #21780]
2025-12-17 18:56:22 +09:00
Misaki Shioi
f45b1e3a1b
Update NEWS.md for Socket (#15608) 2025-12-17 18:53:34 +09:00
Nobuyoshi Nakada
bd4353ba7a CI: Assume all C source files are UTF-8 now 2025-12-17 17:38:52 +09:00
Nobuyoshi Nakada
f286e70019 win32: Set the source code charset to UTF-8 2025-12-17 17:38:52 +09:00
Nobuyoshi Nakada
61bab18890 Rename to struct rbimpl_size_overflow_tag
This struct is used for addition not only for multiplication, so
remove the word `mul`, and make the member names more descriptive.
2025-12-17 17:35:58 +09:00
Akinori Musha
79f36c544a Revert the override of Enumerator#to_set that performed size checks
[Bug #21780]
2025-12-17 17:30:24 +09:00
Misaki Shioi
54d3945ee5
Add host information to timeout error messages in TCPSocket.new and Socket.tcp (#15582)
This change adds host information to the error messages shown when a timeout occurs while passing timeout options to `TCPSocket.new` or `Socket.tcp`, for improved usability.
(When the `fast_fallback option` is enabled, there may be multiple possible destinations, so the host name is shown instead of an IP address.)

As part of this change, the error messages in `Addrinfo.getaddrinfo` and `Addrinfo#connect_internal`, both of which are used by `Socket.tcp`, have also been improved in the same way.
2025-12-17 16:16:32 +09:00
Yusuke Endoh
1506c489ee Update NEWS.md for improvements of error backtrace 2025-12-17 16:12:28 +09:00
git
38310fe79d Update default gems list at 26447b3597ab95af7cc220c641a1bd [ci skip] 2025-12-17 06:48:34 +00:00
Hiroshi SHIBATA
26447b3597 [ruby/net-http] v0.9.1
https://github.com/ruby/net-http/commit/8cee86e939
2025-12-17 15:47:43 +09:00
Kazuki Yamaguchi
b80fc8bd84 [ruby/net-http] Freeze more constants for Ractor compatibility
Freeze Net::HTTP::SSL_ATTRIBUTES and IDEMPOTENT_METHODS_. Both constants
have been marked as :nodoc:.

Together with https://github.com/ruby/openssl/issues/521, this enables
HTTPS clients in non-main Ractors on Ruby 4.0.

https://github.com/ruby/net-http/commit/f24b3b358b
2025-12-17 15:47:43 +09:00
Hiroshi SHIBATA
fedafec78b [ruby/net-http] v0.9.0
https://github.com/ruby/net-http/commit/3ccf0c8e6a
2025-12-17 15:47:43 +09:00
Hiroshi SHIBATA
df18f3baa6 Bundle strscan-3.1.6 2025-12-17 15:47:43 +09:00
Hiroshi SHIBATA
d5257bea48 Bundle stringio-3.2.0 2025-12-17 15:47:43 +09:00
Hiroshi SHIBATA
8e25812194 [ruby/timeout] v0.6.0
https://github.com/ruby/timeout/commit/ab79dfff47
2025-12-17 15:47:43 +09:00
Hiroshi SHIBATA
01624492ec [ruby/time] v0.4.2
https://github.com/ruby/time/commit/387292f5d2
2025-12-17 15:47:43 +09:00
Hiroshi SHIBATA
8850807eb1 [ruby/psych] v5.3.1
https://github.com/ruby/psych/commit/8345af9ffb
2025-12-17 15:47:43 +09:00
Misaki Shioi
7b5691c3b0
Socket.tcp and TCPSocket.new raises IO::TiemoutError with user specified timeout (#15602)
* `Socket.tcp` and `TCPSocket.new` raises `IO::TiemoutError` with user specified timeout

In https://github.com/ruby/ruby/pull/11880, `rsock_connect()` was changed to raise `IO::TimeoutError` when a user-specified timeout occurs.
However, when `TCPSocket.new` attempts to connect to multiple destinations, it does not use `rsock_connect()`, and instead raises `Errno::ETIMEDOUT` on timeout.
As a result, the exception class raised on timeout could differ depending on whether there were multiple destinations or not.

To align this behavior with the implementation of `rsock_connect()`, this change makes `TCPSocket.new` raise `IO::TimeoutError` when a user-specified timeout occurs.
Similarly, `Socket.tcp` is updated to raise `IO::TimeoutError` when a timeout occurs within the method.
(Note that the existing behavior of `Addrinfo#connect_internal`, which Socket.tcp depends on internally and which raises `Errno::ETIMEDOUT` on timeout, is not changed.)

* [ruby/net-http] Raise `Net::OpenTimeout` when `TCPSocket.open` raises `IO::TimeoutError`.

With the changes in https://github.com/ruby/ruby/pull/15602, `TCPSocket.open` now raises `IO::TimeoutError` when a user-specified timeout occurs.
This change updates #connect to handle this case accordingly.

https://github.com/ruby/net-http/commit/f64109e1cf
2025-12-17 15:02:26 +09:00
git
4c38419eb8 Update default gems list at 0e2962f917db1b20a6d34b6105b376 [ci skip] 2025-12-17 05:20:00 +00:00
Nobuyoshi Nakada
0e2962f917
[ruby/io-wait] bump up to 0.4.0
https://github.com/ruby/io-wait/commit/ae676c9d6d
2025-12-17 14:16:38 +09:00
Yusuke Endoh
e354e9ba10 refactor: utilize a predefined macro 2025-12-17 12:37:13 +09:00
Nobuyoshi Nakada
7c402d2c27 IO::Buffer: Warn as experimental at allocation
Previously, warned only in `new` and `map`, but not `for` and
`string`.
2025-12-17 12:35:38 +09:00
Nobuyoshi Nakada
c353b62529 [Bug #21787] IO::Buffer: Check addition overflows
https://hackerone.com/reports/3437743
2025-12-17 12:35:38 +09:00
Nobuyoshi Nakada
9519d16381 IO::Buffer: Guard arguments from GC
At least, `string` in `io_buffer_set_string` can be different from
`argv[0]` after `rb_str_to_str` call.  The other cases may not be
necessary.
2025-12-17 12:35:38 +09:00
Nobuyoshi Nakada
f430fbbfac IO::Buffer: Fill the test for IO::Buffer#clear 2025-12-17 12:35:38 +09:00
git
87274c7203 Update default gems list at 3b66efda523fc33070aee6097898db [ci skip] 2025-12-17 03:13:25 +00:00
Hiroshi SHIBATA
3b66efda52 Bundle RubyGems 4.0.2 and Bundler 4.0.2 2025-12-17 12:12:34 +09:00
Hiroshi SHIBATA
2117e612ca Disabled gem sync for Ruby 4.0 release 2025-12-17 11:11:52 +09:00
Misaki Shioi
74a365310c
Fix: Recalculate the timeout duration considering open_timeout (#15596)
This change updates the behavior so that, when there is only a single destination and `open_timeout` is specified, the remaining `open_timeout` duration is used as the connection timeout.
2025-12-17 11:11:39 +09:00
Peter Zhu
f483484fc6 [DOC] Fix call-seq of Method#box 2025-12-16 21:03:57 -05:00
Daisuke Aritomo
0fe111caa6 Respect encoding of ID in exception messages 2025-12-16 17:15:59 -08:00
Daisuke Aritomo
cbcbbb2fbe Let Ractor::IsolationError report correct constant path
Before this patch, Ractor::IsolationError reported an incorrect constant
path when constant was found through `rb_const_get_0()`.

In this code, Ractor::IsolationError reported illegal access against
`M::TOPLEVEL`, where it should be `Object::TOPLEVEL`.

```ruby
TOPLEVEL = [1]

module M
  def self.f
    TOPLEVEL
  end
end

Ractor.new { M.f }.value
```

This was because `rb_const_get_0()` built the "path" part referring to
the module/class passed to it in the first place. When a constant was
found through recursive search upwards, the module/class which the
constant was found should be reported.

This patch fixes this issue by modifying rb_const_search() to take a
VALUE pointer to be filled with the module/class where the constant was
found.

[Bug #21782]
2025-12-16 17:15:59 -08:00
BurdetteLamar
2d01406644 [DOC] Harmonize rb_div methods 2025-12-16 17:47:08 -05:00
Benoit Daloze
5e27581c3b ZJIT: Use rb_zjit_writebarrier_check_immediate() instead of rb_gc_writebarrier() in gen_write_barrier()
* To avoid calling rb_gc_writebarrier() with an immediate value in gen_write_barrier(),
  and avoid the LIR jump issue.
2025-12-16 21:00:27 +01:00
Benoit Daloze
cc048f7571 Revert "ZJIT: Do not call rb_gc_writebarrier() with an immediate value in gen_write_barrier()"
* This reverts commit 623559faa3dd0927b4034a752226a30ae8821604.
* There is an issue with the jump in LIR, see https://github.com/ruby/ruby/pull/15542.
2025-12-16 21:00:27 +01:00
Benoit Daloze
04edf3d993 ZJIT: Add a VALUE#write_barrier helper method to deduplicate logic 2025-12-16 21:00:27 +01:00
Benoit Daloze
49cecd360f ZJIT: Guard other calls to rb_gc_writebarrier() with a !special_const_p() check 2025-12-16 21:00:27 +01:00
Benoit Daloze
68174c31e4 ZJIT: Do not call rb_gc_writebarrier() with an immediate value in gen_write_barrier() 2025-12-16 21:00:27 +01:00
Benoit Daloze
4d4f414a60 Use RBIMPL_ASSERT_OR_ASSUME instead of ASSUME for better errors when it does not hold 2025-12-16 21:00:27 +01:00
Jean Boussier
094418a6de gc.h: Reintroduce immediate guard in rb_obj_written
This guard was removed in https://github.com/ruby/ruby/pull/13497
on the justification that some GC may need to be notified even for
immediate.

But the two currently available GCs don't, and there are plenty
of assumtions GCs don't everywhere, notably in YJIT and ZJIT.

This optimization is also not so micro (but not huge either).
I routinely see 1-2% wasted there on micro-benchmarks.

So perhaps if in the future we actually need this, it might make
sense to introduce a way for GCs to declare that as an option,
but in the meantime it's extra overhead with little gain.
2025-12-16 21:00:27 +01:00
Alan Wu
eaa952b536 YJIT: Print Rc strong and weak count on assert failure
For <https://bugs.ruby-lang.org/issues/21716>, the panic is looking like
some sort of third party memory corruption, with YJIT taking the fall.
At the point of this assert, the assembler has dropped, so there's
nothing in YJIT's code other than JITState that could be holding on to
these transient `PendingBranchRef`.

The strong count being more than a handful or the weak count is non-zero
shows that someone in the process (likely some native extension)
corrupted the Rc's counts.
2025-12-16 14:56:40 -05:00
Alan Wu
f3d1557d5c
Revert "ZJIT: Allow ccalls above 7 arguments"
This reverts commit 2f151e76b5dc578026706b31f054d5caf5374b05.

The SP decrement (push) before the call do not match up with
the pops after the call, so registers were restored incorrectly.

Code from:

    ./miniruby --zjit-call-threshold=1 --zjit-dump-disasm -e 'p Time.new(1992, 9, 23, 23, 0, 0, :std)'

    str x11, [sp, #-0x10]!
    str x12, [sp, #-0x10]!
    stur x7, [sp]              # last argument
    mov x0, x20
    mov x7, x6
    mov x6, x5
    mov x5, x4
    mov x4, x3
    mov x3, x2
    mov x2, x1
    ldur x1, [x29, #-0x20]
    mov x16, #0xccfc
    movk x16, #0x2e7, lsl #16
    movk x16, #1, lsl #32
    blr x16
    ldr x12, [sp], #0x10       # supposed to match str x12, [sp, #-0x10]!, but got last argument
    ldr x11, [sp], #0x10
2025-12-16 14:53:31 -05:00
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