Commit graph

92768 commits

Author SHA1 Message Date
Jeremy Evans
0b23a8db60 Update dependencies for addition of set.h to public headers 2025-07-11 15:24:23 +09:00
Jeremy Evans
2ab38691a2 Add Set C-API
This should be a minimal C-API needed to deal with Set objects. It
supports creating the sets, checking whether an element is the set,
adding and removing elements, iterating over the elements, clearing
a set, and returning the size of the set.

Co-authored-by: Nobuyoshi Nakada <nobu.nakada@gmail.com>
2025-07-11 15:24:23 +09:00
Jeremy Evans
08d4f7893e Rename some set_* functions to set_table_*
These functions conflict with the planned C-API functions. Since they
deal with the underlying set_table pointers and not Set instances,
this seems like a more accurate name as well.
2025-07-11 15:24:23 +09:00
Yusuke Endoh
b2fdd26417 Lookbehind regexp must be fixed-length
Fixes [Bug #21507]
2025-07-11 15:19:32 +09:00
Alan Wu
1317377fa7 ZJIT: A64: Have add/sub to SP be single-instruction
Previously a missed optimization for add followed by mov. While we're
at it, have Add and Sub share the same match arm in arm64_split().
2025-07-11 15:08:49 +09:00
Misaki Shioi
0058bee57e
Fix heap-use-after-free in rb_getaddrinfo (#13856)
This change addresses the following ASAN error:

```
==1973462==ERROR: AddressSanitizer: heap-use-after-free on address 0x5110002117dc at pc 0x749c307c8a65 bp 0x7ffc3af331d0 sp 0x7ffc3af331c8
READ of size 4 at 0x5110002117dc thread T0
    #0 0x749c307c8a64 in rb_getaddrinfo /tmp/ruby/src/trunk_asan/ext/socket/raddrinfo.c:564:14
    #1 0x749c307c8a64 in rsock_getaddrinfo /tmp/ruby/src/trunk_asan/ext/socket/raddrinfo.c:1008:21
    #2 0x749c307cac48 in rsock_addrinfo /tmp/ruby/src/trunk_asan/ext/socket/raddrinfo.c:1049:12
    #3 0x749c307b10ae in init_inetsock_internal /tmp/ruby/src/trunk_asan/ext/socket/ipsocket.c:62:23
    #4 0x562c5b2e327e in rb_ensure /tmp/ruby/src/trunk_asan/eval.c:1080:18
    #5 0x749c307aafd4 in rsock_init_inetsock /tmp/ruby/src/trunk_asan/ext/socket/ipsocket.c:1318:12
    #6 0x749c307b3b78 in tcp_svr_init /tmp/ruby/src/trunk_asan/ext/socket/tcpserver.c:39:12
```

Fixed to avoid accessing memory that has already been freed after calling `free_getaddrinfo_arg`.
2025-07-11 14:47:18 +09:00
Luke Gruber
a02dcbfd46 Remove accidentally committed method Module.gccct_clear_table
This was probably meant to be only for debugging. It was introduced in
the big namespace on read commit: 382645d440
2025-07-11 10:15:08 +09:00
Takashi Kokubun
0e2bae82dc
ZJIT: Print a message about ZJIT_RB_BUG when unused (#13852) 2025-07-10 18:12:29 -07:00
John Hawthorn
6c66458070 Fix rb_eSystemExit raised in Ractor
[Bug #21505]

Previously `Ractor.new { exit }.join` would hang because SystemExit was
special cased.

This commit updates this to take the same path as other exceptions,
which wraps the exception in a Ractor::RemoteError and does not end up
exiting the main Ractor. I don't know if that's what this should do, but
I think it's a reasonable behaviour as calling exit() in a Ractor is
odd.

    in 'Ractor#join': thrown by remote Ractor. (Ractor::RemoteError)
       from -e:1:in '<main>'
    in 'Kernel#exit': exit (SystemExit)
            from -e:1:in 'block in <main>'
2025-07-10 15:57:08 -07:00
Max Bernstein
470e11a411 ZJIT: Mark Snapshot as having an output
Other instructions use it as an operand and #13814 especially needs it
to have an output for validation.
2025-07-10 17:10:50 -04:00
Max Bernstein
45be0e99a8 ZJIT: Validate that each IR instruction appears at most once 2025-07-10 17:10:50 -04:00
Takashi Kokubun
b1828cbbfe
ZJIT: Implement patch points on BOP redefinition (#13850)
Co-authored-by: Max Bernstein <max@bernsteinbear.com>
2025-07-10 13:40:40 -07:00
Ken Jin
214983bd9b
ZJIT: Add def-use validator via dataflow analysis (#13814)
This PR adds a validator based on dataflow analysis to ZJIT. It checks that all uses are dominated by a GEN-DEF prior.

See issue https://github.com/Shopify/ruby/issues/591

This is especially useful in validating optimizations don't zap away instructions that are actually needed, e.g. DCE.

Also included: a slight refactor of the DCE code to its own function, so I can reuse it.

Note: the algorithm uses the worklist algorithm rather than the iterative version for faster convergence.

Co-Authored-By: Max Bernstein <ruby@bernsteinbear.com>
2025-07-10 19:11:54 +00:00
Takashi Kokubun
9ab80a7455
ZJIT: Avoid optimizing locals on eval (#13840)
* ZJIT: Avoid optimizing locals on eval

* Maintain the local state for eval
2025-07-10 12:08:09 -07:00
Peter Zhu
9d41541b0c Fix unused variable warnings in default.c in modular GC
The asan and valgrind macros when BUILDING_MODULAR_GC don't use the variables
which could the compiler to emit unused variable warnings.
2025-07-10 11:56:22 -04:00
Jean Boussier
1fb4929ace Make rb_enc_autoload_p atomic
Using `encoding->max_enc_len` as a way to check if the encoding
has been loaded isn't atomic, because it's not atomically set
last.

Intead we can use a dedicated atomic value inside the encoding table.
2025-07-10 17:18:20 +02:00
Burdette Lamar
51252ef8d7
[DOC] Tweaks for String#concat (#13836) 2025-07-10 10:40:49 -04:00
BurdetteLamar
a1acba6d14 [DOC] Tweaks for String#codepoints 2025-07-10 10:02:22 -04:00
Nobuyoshi Nakada
800de9891e
[Bug #19417] Update version guard 2025-07-10 21:42:28 +09:00
Misaki Shioi
cdeb9c4d70
Fix timeout in Addrinfo.getaddrinfo to actually take effect (#13803)
[Bug #21506] Fix timeout in Addrinfo.getaddrinfo to actually take effect

This change fixes an issue where the timeout option in `Addrinfo.getaddrinfo` was not functioning as expected.

It also addresses a related issue where specifying `fast_fallback: false` with `resolv_timeout` for `Socket.tcp` and`TCPSocket.new` would have no effect.

The timeout option was originally introduced in:
6382f5cc91

However, the value was noy used in current implementation:
3f0e0d5c8b/ext/socket/raddrinfo.c (L1282-1308)

Therefore, even if a timeout is specified and the duration elapses during name resolution, nothing happens. This is clearly not the intended behavior.

`Addrinfo.getaddrinfo` has been made interruptible as of Feature #19965.
This change uses that feature to interrupt name resolution when the specified timeout period elapses, raising a user-specified timeout error.
The timeout can be specified in milliseconds.

The same issue affects `Socket.tcp` and `TCPSocket.new` when `resolv_timeout` is set along with `fast_fallback: false`.
`resolv_timeout` was introduced in the following commits:
6382f5cc91
511fe23fa2

The reason is that with `fast_fallback: false`, these methods internally call the same `rsock_getaddrinfo()` as `Addrinfo.getaddrinfo`.
This change addresses that as well.
2025-07-10 21:35:13 +09:00
Janosch Müller
bd18238a0e [Bug #19417] Make word prop match join_control ...
... to conform to UTS 18 as mentioned in https://bugs.ruby-lang.org/issues/19417#note-3

https://unicode.org/reports/tr18/#word states word should match join_control chars.

It currently does not:

```ruby
[*0x0..0xD799, *0xE000..0x10FFFF].map { |n| n.chr 'utf-8' } => all_chars
all_chars.grep(/\p{join_control}/) => jc
jc.count # => 2
jc.grep(/\p{word}/).count # => 0
```
2025-07-10 21:28:41 +09:00
Hiroshi SHIBATA
65a0f46880 Warn to use tsort for Ruby 3.6 that will be released at 2026 2025-07-10 16:48:16 +09:00
Nobuyoshi Nakada
bec1ff625b
Sort COMMONOBJS alphabetically 2025-07-10 15:45:27 +09:00
Hiroshi SHIBATA
8cc109a86f [rubygems/rubygems] Update vendored resolv to 0.6.2
afbbc02763
2025-07-10 15:40:07 +09:00
John Hawthorn
581da51cb5 Fix whitespace on some RB_VM_LOCKING calls 2025-07-09 17:28:47 -07:00
Takashi Kokubun
f5085c70f2
ZJIT: Mark profiled objects when marking ISEQ (#13784) 2025-07-09 16:03:23 -07:00
Stan Lo
1df94aaf08 ZJIT: Name side-exit test cases correctly 2025-07-09 17:50:41 -04:00
Stan Lo
e2a81c738c ZJIT: Optimize opt_and and opt_or instructions for Fixnum 2025-07-09 17:50:41 -04:00
Stan Lo
10b582dab6 ZJIT: Profile opt_and and opt_or instructions 2025-07-09 17:50:41 -04:00
BurdetteLamar
b146eae3b5 [DOC] Tweaks for String#clear 2025-07-09 14:42:19 -04:00
BurdetteLamar
6c77a0c62b [DOC] Tweaks for String#chop 2025-07-09 14:41:51 -04:00
BurdetteLamar
3baed2ea38 [DOC] Tweaks for String#chr 2025-07-09 14:41:11 -04:00
BurdetteLamar
94e702b0ba [DOC] Tweaks for String#chop 2025-07-09 13:38:53 -04:00
John Hawthorn
54f28c1db9 Avoid concurrently overflowing of shape_id
Previously it was possible for two atomic increments of next_shape_id
running concurrently to overflow MAX_SHAPE_ID. For this reason we need
to do the test atomically with the allocation in shape_alloc returning
NULL.

This avoids overflowing next_shape_id by repeatedly attempting a CAS.
Alternatively we could have allowed incrementing past MAX_SHAPE_ID and
then clamping in rb_shapes_count, but this seems simpler.
2025-07-09 10:38:04 -07:00
John Hawthorn
cfc006d410 Always use atomics to get the shape count
When sharing between threads we need both atomic reads and writes. We
probably didn't need to use this in some cases (where we weren't running
in multi-ractor mode) but I think it's best to be consistent.
2025-07-09 10:38:04 -07:00
John Hawthorn
5dfd86cf3f Fix off-by-one in shape_tree_mark/shape_tree_compact
This was using < so subtract one from the last shape id would have us
miss the last inserted shape. I think this is unlikely to have caused
issues because I don't think the newest shape will ever have edges.

We do need to use `- 1` because otherwise RSHAPE wraps around and
returns the root shape.
2025-07-09 10:38:04 -07:00
BurdetteLamar
1de0b28cbb [DOC] Tweaks for String#chomp 2025-07-09 11:54:23 -04:00
BurdetteLamar
f17e5c4d5a [DOC] Tweaks for String#chomp! 2025-07-09 11:54:07 -04:00
Andrew Konchin
087387794a Update to ruby/spec@ed254ba 2025-07-09 15:11:17 +02:00
Nobuyoshi Nakada
ba246c5a16
[ruby/io-wait] Revert "Fix dependency for ruby 2.6"
This reverts commit 2eb3841e9c.

Ruby 2.6 support has been dropped.

bcc343683e
2025-07-09 20:18:32 +09:00
Nobuyoshi Nakada
0c1c3ffa22 [ruby/io-wait] Revert https://github.com/ruby/io-wait/pull/9 "Make
the gem a noop on Rubies older than
2.6"

This reverts commit 75fcb74c32.

The version that does nothing with pre-ruby 2.6 has already been
released, so there is no longer need to consider older rubies in newer
versions.

930d2f0d07
2025-07-09 10:34:56 +00:00
Nobuyoshi Nakada
ddeefa2e7e [ruby/io-wait] Bump up the required ruby version
io-wait became a default gem at ruby 3.0.
Even it can be installed on earlier versions, but the standard library
will be loaded instead of the installed gem.

15b96736cd
2025-07-09 10:34:54 +00:00
Nobuyoshi Nakada
25afe7ef64
Rename variables to suit each method 2025-07-09 17:56:38 +09:00
Nobuyoshi Nakada
cd10afedb5
Removed a left over from c71a60c1dd
0a0eb2807e has already replaced most of that code.
2025-07-09 17:56:37 +09:00
Nobuyoshi Nakada
3f0e0d5c8b [ruby/io-nonblock] Bump up the required ruby version
io-nonblock became a default gem at ruby 3.0.
Even it can be installed on earlier versions, but the standard library
will be loaded instead of the installed gem.

c86d0d37af
2025-07-09 06:59:58 +00:00
Sweta Sanghavi
4ed2757543 [rubygems/rubygems] Update gemspec based on provided github username when exists
* Conditionally set changelog_url if gh username passed
and enabled
* conditionally set homepage, source code uri, homepage uri when gh
  username passed in
* update documentation to say username will also be used for gemspec file

1c1ada593b
2025-07-09 13:48:37 +09:00
Peteris Rudzusiks
3feba181ed [rubygems/rubygems] Let s3_uri_signer accept the HTTP method
35fc7f9547
2025-07-09 13:48:37 +09:00
Peteris Rudzusiks
5d880b75ef [rubygems/rubygems] Correctly sign S3 HEAD requests
We sometimes send HEAD requests. The s3_uri_signer.rb code allways assumed GETs.
This lead to consistently getting 403 responses back from S3. Recently, S3
attempted to change the behaviour of how 403s are handled when TCP connections
are reused,  which escalated this bug from "just noise" to "breaks gem installs".
They've reverted that behaviour, so the severity of this problem is back to
"just noise". Either way, it's a bug in rubygems and warrants a fix it.

c38f502b73
2025-07-09 13:48:36 +09:00
Peteris Rudzusiks
af6012b942 [rubygems/rubygems] Fix date format in S3 URI signer
%M is minute of the hour.
%m is month of year.
We want the former, not the latter.

d7ca3fa279
2025-07-09 13:48:35 +09:00
David Rodríguez
c6da019770 [rubygems/rubygems] Add blank line after every question
To try make output a bit less messy.

92c8bc6769
2025-07-09 13:48:34 +09:00