Commit graph

89125 commits

Author SHA1 Message Date
Hiroshi SHIBATA
b44272fcb4 Port test_warn_bundled_gems.rb to RSpec example 2024-11-15 08:16:03 +09:00
Takashi Kokubun
31bdffb5b9
YJIT: Specialize String#dup (#12090) 2024-11-14 18:15:39 -05:00
tomoya ishida
8f3a6ebcf4 [ruby/reline] Drop loading terminfo, remove fiddle dependency in
non-windows environment.
(https://github.com/ruby/reline/pull/769)

Reline works perfectly in most major terminal emulators without terminfo.
In minor/old terminal emulator, we used to get key bindings from terminfo, but I think it is not used so much.

3ceba3bff7
2024-11-14 23:14:18 +00:00
Yusuke Endoh
4074c6b427 Fix a stack-buffer-overflow bug
http://ci.rvm.jp/results/trunk_asan@ruby-sp1/5408428
```
==3159643==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x796cf8f09041 at pc 0x6539bbf68ded bp 0x796cfadffcf0 sp 0x796cfadff4b8
READ of size 2 at 0x796cf8f09041 thread T13
    #0 0x6539bbf68dec in strlen (/tmp/ruby/build/trunk_asan/ruby+0x18edec) (BuildId: cca267c7ae091060e1b82a6b4ed1aeaf00edebab)
```
2024-11-14 11:29:47 -06:00
Takashi Kokubun
7e2f9eaccd
YJIT: Specialize Integer#pred (#12082) 2024-11-14 12:04:48 -05:00
Misaki Shioi
fd4b27472e
Do not wait connection attempt delay without in progress fds (#12087)
Do not wait Connection Attempt Delay without in progress fds

Reset Connection Attempt Delay when connection fails and there is no other socket connection in progress.
This is intended to resolve an issue that was temporarily worked around in Pull Request #12062.

`TCPServer::new` (used in tests such as `TestNetHTTP_v1_2_chunked#test_timeout_during_non_chunked_streamed_HTTP_session_write`) can only connect over either IPv6 or IPv4, depending on the environment.
Since HEv2 attempts to connect over IPv6 first, environments where IPv6 connections are unavailable return ECONNREFUSED immediately.
In such cases, the client should immediately retry the connection over IPv4.
However, HEv2 includes a specification for a "Connection Attempt Delay," where it waits 250ms after the previous connection attempt before starting the next one.
This delay causes Net::OpenTimeout (100ms) to be exceeded while waiting for the next connection attempt to start.

With this change, when a connection attempt fails, if there are sockets still attempting to connect and there are addresses yet to be tried, the Connection Attempt Delay will be resetted, allowing the next connection attempt to start immediately.

---

Additionally, the following minor fixes have been made:

- The `nfds` value used for select(2) is now reset with each wait.
2024-11-15 00:25:59 +09:00
Peter Zhu
54ff9d3525 Remove dependency of version.c on gc/gc.h
version.c does not depend on gc/gc.h.
2024-11-14 07:50:05 -06:00
Matt Valentine-House
42501015b4 rb_raise when attempting to set the GC implementation name
Instead of silently ignoring the key, we should raise to clearly tell
the user that this key is read-only.
2024-11-14 10:46:36 +00:00
Matt Valentine-House
6795fc4981 rb_bug if rb_gc_impl_active_gc_name is too long
This avoids the need to malloc, and reduces the complexity of truncating
the long string for display in RUBY_DESCRIPTION.

The developer of a GC implementation should be responsible for giving it
a succinct name.
2024-11-14 10:46:36 +00:00
Matt Valentine-House
ee290c94a3 Include the currently active GC in RUBY_DESCRIPTION
This will add +MOD_GC to the version string and Ruby description when
Ruby is compiled with shared gc support.

When shared GC support is compiled in and a GC module has been loaded
using RUBY_GC_LIBRARY, the version string will include the name of
the currently active GC as reported by the rb_gc_active_gc_name function
in the form

+MOD_GC[gc_name]

[Feature #20794]
2024-11-14 10:46:36 +00:00
Matt Valentine-House
fa10441981 Expose GC.config[:implementation], to query the currently active GC
And a default and readonly key to the GC.config hash that names the
current GC implementation.

This is provided by each implementation by the API function
rb_gc_impl_active_gc_name
2024-11-14 10:46:36 +00:00
Hiroshi SHIBATA
8a4ce4e9a9 [rubygems/rubygems] URI::DEFAULT_PARSER.escape is obsoleted. We should use URI::RFC2396_PARSER.escape explicitly
64f026c9d4
2024-11-14 07:44:01 +00:00
Hiroshi SHIBATA
331f1647d7 [rubygems/rubygems] Revert "mustermann depends on URI::RFC2396_PARSER behavior"
This reverts commit 82b25dd75a.

16adf53f23
2024-11-14 07:44:01 +00:00
git
028958f9ad Update default gems list at 0f5e3dca5a [ci skip] 2024-11-14 03:50:17 +00:00
Hiroshi SHIBATA
0f5e3dca5a [ruby/uri] Bump up v1.0.2
e46960a467
2024-11-14 03:49:15 +00:00
Hiroshi SHIBATA
310e6603a2 [ruby/uri] Check existence constants only URI module
b6f583369a
2024-11-14 03:32:13 +00:00
git
44fb1de9e9 Update default gems list at 43285f543b [ci skip] 2024-11-14 02:23:16 +00:00
Hiroshi SHIBATA
43285f543b [ruby/pp] Bump up v0.6.1
812933668d
2024-11-14 02:22:14 +00:00
David Rodríguez
7ece47e0de Update vendored thor to 1.3.2 2024-11-14 11:21:39 +09:00
David Rodríguez
99c35edae1 Update vendored timeout to 0.4.2 2024-11-14 11:21:39 +09:00
David Rodríguez
d9c754ab44 Update vendored securerandom to 0.3.2 2024-11-14 11:21:39 +09:00
David Rodríguez
0ef7d59ef2 Update vendored resolv to 0.5.0 2024-11-14 11:21:39 +09:00
David Rodríguez
26036b1248 Update vendored net-http to 0.5.0 2024-11-14 11:21:39 +09:00
David Rodríguez
570336b80f Update vendored fileutils to 1.7.3 2024-11-14 11:21:39 +09:00
David Rodríguez
cadf559a99 Update vendored optparse to 0.6.0 2024-11-14 11:21:39 +09:00
David Rodríguez
abb6f5c8bc [rubygems/rubygems] Fix bin/rake spec:all task
Only in CI, if two different test runs are started (like `bin/rake
spec:all` does), the second one would not install the dev version of
Bundler and would fail to start.

This commit makes it work the same locally and in CI.

7a5ca6c40f
2024-11-14 11:21:39 +09:00
David Rodríguez
bf569c80ea [rubygems/rubygems] I don't see how this could happen
8b6f9b7f05
2024-11-14 11:21:39 +09:00
David Rodríguez
4fc82519a0 [rubygems/rubygems] Make sure bundle viz specs are actually run
These are marked as realworld, but the realworld workflow file does not
install graphviz, so the specs are actually skipped.

These are not actually realworld, so remove that tag. Now they'll be run
together with the reset of specs in the standard workflow file, which
does install `graphviz`.

e865fcaa22
2024-11-14 11:21:39 +09:00
Kazuki Yamaguchi
a0f1f16145 asn1: fix ObjectId#==
Compare by the dotted decimal notation rather than the NID.

OpenSSL::ASN1::ObjectId can store OIDs that are not registered in
OpenSSL's internal table. NID is not defined for such an OID, but it is
not an error.

The == method also should not raise TypeError if the other object is
not an instance of OpenSSL::ASN1::ObjectId.

Fixes: https://github.com/ruby/openssl/issues/791
2024-11-14 11:21:39 +09:00
Kazuki Yamaguchi
4e7e2e9e89 [ruby/openssl] pkcs7: fix memory leak in error path of PKCS7.new and .read_smime
A follow-up to commit 27e11f2d1d and 07eceb7f63. The PKCS7 object
must be freed before raising an exception.

172eee4665
2024-11-14 11:21:39 +09:00
Kazuki Yamaguchi
419fb2f3b9 [ruby/openssl] x509: fix handling of multiple URIs in Certificate#crl_uris
The implementation of OpenSSL::X509::Certificate#crl_uris makes the
assumption that each DistributionPoint in the CRL distribution points
extension contains a single general name of type URI. This is not
guaranteed by RFC 5280. A DistributionPoint may contain zero or more
than one URIs.

Let's include all URIs found in the extension. If only non-URI pointers
are found, return nil.

Fixes: https://github.com/ruby/openssl/issues/775

71f4fef2fa
2024-11-14 11:21:39 +09:00
Kazuki Yamaguchi
97be56fc62 [ruby/openssl] test_x509cert.rb: break up test_extension into smaller units
test_extesion is testing too many features at once and is hard to
navigate. Let's split each chunk apart for more clarity.

461cfcb070
2024-11-14 11:21:39 +09:00
Jean Boussier
a4183781ec [ruby/json] Only use the key cache if the Hash is in an Array
Otherwise the likeliness of seeing that key again is really low, and looking up
the cache is just a waste.

Before:

```
== Parsing small hash (65 bytes)
ruby 3.4.0dev (2024-11-13T12:32:57Z fstr-update-callba.. 9b44b455b3) +YJIT +PRISM [arm64-darwin24]
Warming up --------------------------------------
                json   343.049k i/100ms
                  oj   213.943k i/100ms
          Oj::Parser    31.583k i/100ms
           rapidjson   303.433k i/100ms
Calculating -------------------------------------
                json      3.704M (± 1.5%) i/s  (270.01 ns/i) -     18.525M in   5.003078s
                  oj      2.200M (± 1.1%) i/s  (454.46 ns/i) -     11.125M in   5.056526s
          Oj::Parser    285.369k (± 4.8%) i/s    (3.50 μs/i) -      1.453M in   5.103866s
           rapidjson      3.216M (± 1.6%) i/s  (310.95 ns/i) -     16.082M in   5.001973s

Comparison:
                json:  3703517.4 i/s
           rapidjson:  3215983.0 i/s - 1.15x  slower
                  oj:  2200417.1 i/s - 1.68x  slower
          Oj::Parser:   285369.1 i/s - 12.98x  slower

== Parsing test from oj (258 bytes)
ruby 3.4.0dev (2024-11-13T12:32:57Z fstr-update-callba.. 9b44b455b3) +YJIT +PRISM [arm64-darwin24]
Warming up --------------------------------------
                json    54.539k i/100ms
                  oj    41.473k i/100ms
          Oj::Parser    24.064k i/100ms
           rapidjson    51.466k i/100ms
Calculating -------------------------------------
                json    549.386k (± 1.6%) i/s    (1.82 μs/i) -      2.781M in   5.064316s
                  oj    417.003k (± 1.3%) i/s    (2.40 μs/i) -      2.115M in   5.073047s
          Oj::Parser    226.500k (± 4.7%) i/s    (4.42 μs/i) -      1.131M in   5.005466s
           rapidjson    526.124k (± 1.0%) i/s    (1.90 μs/i) -      2.676M in   5.087176s

Comparison:
                json:   549385.6 i/s
           rapidjson:   526124.3 i/s - 1.04x  slower
                  oj:   417003.4 i/s - 1.32x  slower
          Oj::Parser:   226500.4 i/s - 2.43x  slower
```

After:

```
== Parsing small hash (65 bytes)
ruby 3.4.0dev (2024-11-13T12:32:57Z fstr-update-callba.. 9b44b455b3) +YJIT +PRISM [arm64-darwin24]
Warming up --------------------------------------
                json   361.394k i/100ms
                  oj   217.203k i/100ms
          Oj::Parser    28.855k i/100ms
           rapidjson   303.404k i/100ms
Calculating -------------------------------------
                json      3.859M (± 2.9%) i/s  (259.13 ns/i) -     19.515M in   5.061302s
                  oj      2.191M (± 1.6%) i/s  (456.49 ns/i) -     11.077M in   5.058043s
          Oj::Parser    315.132k (± 7.1%) i/s    (3.17 μs/i) -      1.587M in   5.065707s
           rapidjson      3.156M (± 4.0%) i/s  (316.88 ns/i) -     15.777M in   5.008949s

Comparison:
                json:  3859046.5 i/s
           rapidjson:  3155778.5 i/s - 1.22x  slower
                  oj:  2190616.0 i/s - 1.76x  slower
          Oj::Parser:   315132.4 i/s - 12.25x  slower

== Parsing test from oj (258 bytes)
ruby 3.4.0dev (2024-11-13T12:32:57Z fstr-update-callba.. 9b44b455b3) +YJIT +PRISM [arm64-darwin24]
Warming up --------------------------------------
                json    55.682k i/100ms
                  oj    40.343k i/100ms
          Oj::Parser    25.119k i/100ms
           rapidjson    51.500k i/100ms
Calculating -------------------------------------
                json    555.808k (± 1.4%) i/s    (1.80 μs/i) -      2.784M in   5.010092s
                  oj    412.283k (± 1.7%) i/s    (2.43 μs/i) -      2.098M in   5.089900s
          Oj::Parser    279.306k (±13.3%) i/s    (3.58 μs/i) -      1.356M in   5.022079s
           rapidjson    517.177k (± 2.7%) i/s    (1.93 μs/i) -      2.626M in   5.082352s

Comparison:
                json:   555808.3 i/s
           rapidjson:   517177.1 i/s - 1.07x  slower
                  oj:   412283.2 i/s - 1.35x  slower
          Oj::Parser:   279306.5 i/s - 1.99x  slower
```

00c45ddc9f
2024-11-14 11:21:39 +09:00
Hiroshi SHIBATA
1bab8bf88f [ruby/uri] Removed duplicated declare step for constants under the URI::RFC2396_REGEXP::PATTERN
60a8bc1575
2024-11-14 02:20:04 +00:00
Hiroshi SHIBATA
1d6c986104 [ruby/uri] Restore constants like URI::REGEXP::PATTERN::IPV6ADDR
ee9a38701a
2024-11-14 02:20:04 +00:00
Nobuyoshi Nakada
e97dcf53a2
Fix the method name in a comment [ci skip] 2024-11-14 09:24:00 +09:00
John Bampton
9783cdb0d7
Update action.yml - fix typo [ci skip] 2024-11-14 09:23:20 +09:00
Takashi Kokubun
30e1d6b5a8
YJIT: Add inline_block_count stat (#12081) 2024-11-13 16:17:29 -05:00
Takashi Kokubun
907146973a Add a comment about Integer#downto Enumerator 2024-11-13 12:27:26 -08:00
Takashi Kokubun
01db456196 Move Array#map to Ruby
Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
2024-11-13 12:27:26 -08:00
Takashi Kokubun
c9a5a71695 Move Array#select to Ruby
Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
2024-11-13 12:27:26 -08:00
Takashi Kokubun
d57d85548f Move Integer#downto to Ruby
Co-Authored-By: Aaron Patterson <tenderlove@ruby-lang.org>
2024-11-13 12:27:26 -08:00
Randy Stauner
beafae9750
YJIT: Specialize String#[] (String#slice) with fixnum arguments (#12069)
* YJIT: Specialize `String#[]` (`String#slice`) with fixnum arguments

String#[] is in the top few C calls of several YJIT benchmarks:
liquid-compile rubocop mail sudoku

This speeds up these benchmarks by 1-2%.

* YJIT: Try harder to get type info for `String#[]`

In the large generated code of the mail gem the context doesn't have
the type info.  In that case if we peek at the stack and add a guard
we can still apply the specialization
and it speeds up the mail benchmark by 5%.

Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
Co-authored-by: Takashi Kokubun (k0kubun) <takashikkbn@gmail.com>

---------

Co-authored-by: Maxime Chevalier-Boisvert <maxime.chevalierboisvert@shopify.com>
Co-authored-by: Takashi Kokubun (k0kubun) <takashikkbn@gmail.com>
2024-11-13 12:25:09 -05:00
Alexis Bernard
202a377d21 [ruby/rdoc] Split list of class and instance methods in two
(https://github.com/ruby/rdoc/pull/1206)

Looking for a method is easier because eyes don't have to skip dashes or
double colon.

6852567640
2024-11-13 16:13:21 +00:00
Jean byroot Boussier
6deeec5d45
Mark strings returned by Symbol#to_s as chilled (#12065)
* Use FL_USER0 for ELTS_SHARED

This makes space in RString for two bits for chilled strings.

* Mark strings returned by `Symbol#to_s` as chilled

[Feature #20350]

`STR_CHILLED` now spans on two user flags. If one bit is set it
marks a chilled string literal, if it's the other it marks a
`Symbol#to_s` chilled string.

Since it's not possible, and doesn't make much sense to include
debug info when `--debug-frozen-string-literal` is set, we can't
include allocation source, but we can safely include the symbol
name in the warning message, making it much easier to find the source
of the issue.

Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com>

---------

Co-authored-by: Étienne Barrié <etienne.barrie@gmail.com>
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2024-11-13 09:20:00 -05:00
Jean Boussier
37a16c7812 string.c: preserve coderange when interning a string
Since `str_do_hash` will most likely scan the string to
compute the coderange, we might as well copy it over in the
interned string in case it's useful later.
2024-11-13 14:14:24 +01:00
Jean Boussier
fae86a701e string.c: Directly create strings with the correct encoding
While profiling msgpack-ruby I noticed a very substantial amout of time
spent in `rb_enc_associate_index`, called by `rb_utf8_str_new`.

On that benchmark, `rb_utf8_str_new` is 33% of the total runtime,
in big part because it cause GC to trigger often, but even then
`5.3%` of the total runtime is spent in `rb_enc_associate_index`
called by `rb_utf8_str_new`.

After closer inspection, it appears that it's performing a lot of
safety check we can assert we don't need, and other extra useless
operations, because strings are first created and filled as ASCII-8BIT
and then later reassociated to the desired encoding.

By directly allocating the string with the right encoding, it allow
to skip a lot of duplicated and useless operations.

After this change, the time spent in `rb_utf8_str_new` is down
to `28.4%` of total runtime, and most of that is GC.
2024-11-13 13:32:32 +01:00
Jean Boussier
bfb4783c01 Move Symbol#name into symbol.rb
This allows to declare it as leaf just like `Symbol#to_s`.

Co-Authored-By: Étienne Barrié <etienne.barrie@gmail.com>
2024-11-13 10:29:07 +01:00
David Rodríguez
ae733a693b [rubygems/rubygems] Include original error when openssl fails to load
440343b791
2024-11-13 08:35:40 +00:00
Hiroshi SHIBATA
38b07a7fee
Revert force_activate feature. It's unnecessary for Ruby 3.4.
I will add this feature for Ruby 3.5 again.
2024-11-13 16:54:20 +09:00