Commit graph

20692 commits

Author SHA1 Message Date
Samuel Chiang
f14995e212 [ruby/openssl] test_pkcs12.rb: don't use KEY_EX/SIG with AWS-LC
AWS-LC does not support the KEY_SIG or KEY_EX flags that were only ever
supported by old MSIE.

d50528b4e2
2025-02-22 15:11:37 +00:00
Samuel Chiang
6f3bd3769b [ruby/openssl] test_fips.rb: account for AWS-LC's FIPS mode
AWS-LC's FIPS mode is decided at compile time. FIPS in AWS-LC can't be
toggled on and off like OpenSSL, so tests that attempt to do so are
incompatible.

027de6732d
2025-02-22 15:11:36 +00:00
Nobuyoshi Nakada
7ef9110b1e [ruby/stringio] Fix SEGV at unget to a null device StringIO
eb4ee49218
2025-02-21 12:06:19 +00:00
Nobuyoshi Nakada
fa6b9f75ef [ruby/stringio] Suppress a warning for the chilled string
4a35291ed3
2025-02-21 12:06:19 +00:00
Jean Boussier
bf6c106d54 [ruby/strscan] scan_integer(base: 16) ignore x suffix if not
followed by hexadecimal
(https://github.com/ruby/strscan/pull/141)

Fix: https://github.com/ruby/strscan/issues/140

`0x<EOF>`, `0xZZZ` should be parsed as `0` instead of not matching at
all.

c4e4795ed2
2025-02-21 11:31:36 +09:00
Charles Oliver Nutter
7d7984642c [ruby/stringio] Allow seek when underlying string is frozen
(https://github.com/ruby/stringio/pull/121)

Fixes https://github.com/ruby/stringio/pull/119. Adds a test for this expectation.

3f90fe44c6
2025-02-21 00:37:40 +00:00
Aaron Patterson
a27758ad4e [ruby/stringio] Make sure shared buffer is copied on mutation
(https://github.com/ruby/stringio/pull/117)

We need to ensure shared buffers are made independent on mutation.
Otherwise we could end up mutating unrelated string buffers.

---------

5101cfb030

Co-authored-by: Aaron Patterson <tenderlove@ruby-lang.org>
Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
Co-authored-by: Aaron Patterson <aaron.patterson@gmail.com>
Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
2025-02-20 00:18:08 +00:00
Kazuki Yamaguchi
c515da3d74 [ruby/openssl] ssl: remove cert_store from start_server test helper
OpenSSL::SSL::SSLContext#cert_store= uses SSL_CTX_set_cert_store(). The
store is used for verifying peer certificates and for building
certificate chains to be sent to the peer if there is no chain
explicitly provided by SSLContext#extra_chain_cert=.

Do not specify it in the common test helper start_server, as most
callers do not require either function. Instead, update individual test
cases that use client certificates to explicitly specify it in ctx_proc.
A more direct test case is added to verify the latter function.

9daecee615
2025-02-19 17:08:16 +00:00
Peter Zhu
ff6b1a03ab Skip TestObjSpace#test_dump_flag_age for MMTk 2025-02-19 09:47:28 -05:00
Peter Zhu
5e45f2a0bc Add age to rb_gc_object_metadata
This will allow ObjectSpace.dump to output the age of the object.
2025-02-19 09:47:28 -05:00
David Rodríguez
4f7dfbe58e
[rubygems/rubygems] Remove no longer necessary JRuby specific test ENV
It does not seem noisy anymore.

060c5e960a
2025-02-19 11:04:09 +09:00
Jeremy Evans
f423f6e10c Ensure IO.copy_stream buffer is an independent string
Otherwise, changes to the buffer by the destination write method
could result in data changing for supposedly independent strings.

Fixes [Bug #21131]
2025-02-18 17:18:16 -08:00
Peter Zhu
80a71bfb1c Fix typo in test_gc_compact.rb [ci skip] 2025-02-18 18:41:57 -05:00
Peter Zhu
0597cbcb1d Fix crash for special constants in too complex generic ivars
We should skip reference updating for entries in too complex generic ivars
that are special constants. This fixes the following crash:

    MAX_SHAPES = 0x80000

    MAX_SHAPES.times do |i|
      o = []
      o.instance_variable_set(:"@foo#{i}", 1)
    end

    o = []

    o.instance_variable_set(:"@a", 123)

    GC.compact
2025-02-18 17:09:28 -05:00
Yusuke Endoh
3a0d00ddfb Add a test for Binding#local_variable* with numbered parameters and it 2025-02-18 16:23:24 +09:00
Kevin Newton
2db365dc83 [ruby/prism] Fix escape unicode curly inline whitespace
Fixes [Bug #21145]

be2d845639
2025-02-17 18:12:03 +00:00
NAITOH Jun
eee9bd1aa4 [ruby/strscan] Fix a bug that scan_until behaves differently with
Regexp and String patterns
(https://github.com/ruby/strscan/pull/138)

Fix https://github.com/ruby/strscan/pull/131

e1cec2e726
2025-02-17 11:04:32 +09:00
Aaron Patterson
8cafa5b8ce Only count VM instructions in YJIT stats builds
The instruction counter is slowing multi-Ractor applications.  I had
changed it to use a thread local, but using a thread local is slowing
single threaded applications.  This commit only enables the instruction
counter in YJIT stats builds until we can figure out a way to gather the
information with lower overhead.

Co-authored-by: Randy Stauner <randy.stauner@shopify.com>
2025-02-14 14:39:35 -05:00
Kevin Newton
deb010ae24 [ruby/prism] Fix up locals test with it parameters
599a96dbfc
2025-02-14 17:32:58 +00:00
Kevin Newton
ee181d1bb7 [ruby/prism] Fix up it indirect writes
Fixes [Bug #21137]

ca493e6797
2025-02-14 16:49:52 +00:00
Masataka Pocke Kuwabara
0cab608d3a
[Bug #21127] Thread deadlock does not display backtraces (#12721)
Previously, Ruby displayed backtraces for each thread on deadlock. However, it has not been shown since Ruby 3.0.
It should display the backtrace for debugging.

Co-authored-by: Jeremy Evans <code@jeremyevans.net>
2025-02-14 16:31:58 +09:00
Jean Boussier
51004c3641
[ruby/strscan] Fix a bug that scan_integer doesn't update matched
data
(https://github.com/ruby/strscan/pull/133)

Fix https://github.com/ruby/strscan/pull/130

Reported by Andrii Konchyn. Thanks!!!

4e5f17f87a
2025-02-14 16:13:26 +09:00
Kevin Newton
127325a4ba [ruby/prism] No writing to numbered parameters
Fixes [Bug #21117]

19d4bab5a0
2025-02-13 20:04:02 +00:00
Kevin Newton
b21e1aed2e [ruby/prism] Fix infinite loop in error recovery
When recovering from a depth error that occurs at the end of the
file, we need to break out of parsing statements.

Fixes [Bug #21114]

a32e268787
2025-02-13 19:12:10 +00:00
Nobuyoshi Nakada
4a67ef09cc
[Feature #21116] Extract RJIT as a third-party gem 2025-02-13 18:01:03 +09:00
Hiroshi SHIBATA
45397f8284
Extend timeout with resolv.rb and Windows platform. It's expired with 10sec sometimes. 2025-02-13 14:13:53 +09:00
Jean Boussier
293ad8a4e9
Fix a compatibility issue with MultiJson.dump(obj, pretty: true)
Fix: https://github.com/ruby/json/issues/748

`MultiJson` pass `State#to_h` as options, and the `as_json`
property defaults to `false` but `false` wasn't accepted by
the constructor.
2025-02-12 13:15:01 +09:00
Kazuki Yamaguchi
dedd05e9c8 [ruby/openssl] pkcs7: add a test case for the data content type
While it is not useful alone, it is still a valid content type. Some
methods on OpenSSL::PKCS7 are only meant to work with the signed-data
or enveloped-data content type. Add some assertions for their behavior
with unsupported content types. The next patches will update the
relevant code.

adb42b5b84
2025-02-11 16:42:25 +00:00
Samuel Chiang
06faf28558 [ruby/openssl] Add build support for AWS-LC
CI Changes
1. I've split the original patch up to make it easier to digest, but
that forces my hand to turn off testing in the AWS-LC CI for the time
being. However, do let me know if you would prefer to review the test
adjustments in the same PR and I can remove the temporary CI workaround.
2. AWS-LC has a few no-op functions and we use -Wdeprecated-declarations
to alert the consuming application of these. I've leveraged the
skip-warnings CI option so that the build doesn't fail.

Build Adjustments
1. AWS-LC FIPS mode is decided at compile time. This is different from
OpenSSL's togglable FIPS switch, so I've adjusted the build to account
for this.
2. AWS-LC does not support for the two KEY_SIG or KEY_EX flags that were
only ever supported by old MSIE.
3. AWS-LC has no current support for post handshake authentication in
TLS 1.3.
4. EC_GROUP structures for named curves in AWS-LC are constant, static,
and immutable by default. This means that the EC_GROUP_set_* functions
are essentially no-ops due to the immutability of the structure. We've
introduced a new API for consumers that depend on the OpenSSL's default
mutability of the EC_GROUP structure called
EC_GROUP_new_by_curve_name_mutable. Since Ruby has a bit of
functionality that's dependent on the mutability of these structures,
I've made the corresponding adjustments to allow things to work as
expected.

e53ec5a101
2025-02-11 15:35:03 +00:00
Peter Zhu
50469809b8 [ruby/mmtk] Use RUBY_TEST_TIMEOUT_SCALE for tests
RUBY_TEST_TIMEOUT_SCALE is set for debug builds because they are slower
to run. We should respect this environment variable in MMTk tests too.

0a66c518bf
2025-02-10 19:33:04 +00:00
Kazuki Yamaguchi
7d10c22a86 [ruby/openssl] Revert "Skip a new test when old OpenSSL"
This reverts commit 8c96a69b0d.

This is no longer necessary since we do not support OpenSSL 1.1.0
anymore.

4987688cb4
2025-02-09 10:26:07 +00:00
Kazuki Yamaguchi
581dbcec79 [ruby/openssl] ssl: prefer SSLContext#max_version= in tests
Avoid using the deprecated OpenSSL::SSL::SSLContext#ssl_version= outside
the tests specifically written for it.

93a564dec2
2025-02-09 10:26:07 +00:00
Kazuki Yamaguchi
64a98decf2 [ruby/openssl] ssl: fix misuse of assert_handshake_error in tests
assert_handshake_error is useful for checking handshake failures
triggered by the peer, as the underlying socket may be closed
prematurely, leading to different exceptions depending on the platform
and timing.

However, when the local end aborts a handshake, the only possible
exception is OpenSSL::SSL::SSLError. Use stricter assertions in such
cases.

637ba65818
2025-02-09 10:26:07 +00:00
Kazuki Yamaguchi
5791c93f8e [ruby/openssl] ssl: refactor test case test_verify_mode_server_cert
Minimize the amount of code inside the assert_raise block to avoid
accidentally catching a wrong exception.

5089b2d311
2025-02-09 10:26:06 +00:00
Kazuki Yamaguchi
a8b36314ec [ruby/openssl] ssl: fix test case test_npn_advertised_protocol_too_long
The list of NPN protocols is validated in SSLContext#setup.

The assert_handshake_error is misleading. The client is unable to start
a handshake at all because the server is not running.

e8db6ffd9e
2025-02-09 10:26:06 +00:00
Kazuki Yamaguchi
1f4fc2e608 [ruby/openssl] ssl: remove start_server_version from tests
Use start_server instead of start_server_version.

start_server_version is a wrapper around start_server that forces the
server to a specific protocol version using the now-deprecated method
SSLSocket#ssl_version=, but it does more than that. The slightly
different method signature and default values are confusing. Let's
use start_server directly.

22ed31d77e
2025-02-09 10:26:06 +00:00
Kazuki Yamaguchi
237c71fc29 [ruby/openssl] ssl: remove start_immediately kwarg from test helper start_server
The keyword argument is no longer used by any test cases.

2f31605d47
2025-02-09 10:26:05 +00:00
Nobuyoshi Nakada
9baa0f8c8c
Enable bundled gems in ruby-runner 2025-02-06 23:12:03 +09:00
Jun Aruga
adbf9c5b36 [ruby/openssl] test_ssl.rb: Test respecting system default min.
7de5ff583a
2025-02-06 14:10:34 +00:00
Étienne Barrié
b4bfbcaddc
Optimize Symbol generation in strict mode
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2025-02-06 16:02:03 +09:00
Étienne Barrié
f865148e19
Fix JSON::Coder to call as_json proc for NaN and Infinity
Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2025-02-06 16:02:03 +09:00
Hiroshi SHIBATA
ec2bd6f74e Skip to existence check fiddle from TestExtLibs 2025-02-05 07:36:59 +09:00
Hiroshi SHIBATA
908529b7e0 Migrate fiddle as bundled gems 2025-02-05 07:36:59 +09:00
Misaki Shioi
1683dadb19
Do not save ResolutionError if resolution succeeds for any address family (#12678)
* Do not save ResolutionError if resolution succeeds for any address family

Socket with Happy Eyeballs Version 2 performs connection attempts and name resolution in parallel.

In the existing implementation, if a connection attempt failed for one address family while name resolution was still in progress for the other, and that name resolution later failed, the method would terminate with a name resolution error.
This behavior was intended to ensure that the final error reflected the most recent failure, potentially overriding an earlier error.

However, [Bug #21088](https://bugs.ruby-lang.org/issues/21088) made me realize that terminating with a name resolution error is unnatural when name resolution succeeded for at least one address family.

This PR modifies the behavior so that if name resolution succeeds for one address family, any name resolution error from the other is not saved.

This PR includes the following changes:

* Do not display select(2) as the system call that caused the raised error, as it is for internal processing

* Fix bug: Get errno with Socket::SO_ERROR in Windows environment with a workaround for tests not passing
2025-02-03 20:26:47 +09:00
Kazuki Yamaguchi
f84d75eecc [ruby/openssl] pkey/ec: remove deprecated PKey::EC::Point#mul(ary, ary [, bn]) form
The method has two forms, each corresponding to EC_POINT_mul() and
EC_POINTs_mul(). The latter form does not work with any OpenSSL or
LibreSSL versions that are still supported by upstream.

The latter form has an extremely confusing behavior, too, and using it
would print a deprecation warning since commit 812de4253d in 2020,
which went to 3.0.0. Let's remove it.

7343d3c559
2025-02-03 09:47:48 +00:00
Kazuki Yamaguchi
5a14f53695 [ruby/openssl] ssl: separate SSLContext#min_version= and #max_version=
Make these methods simple wrappers around
SSL_CTX_set_{min,max}_proto_version().

When we introduced these methods in commit 18603949d3 [1], which went
to v2.1.0, we added a private method to SSLContext that set both the
minimum and maximum protocol versions at the same time. This was to
allow emulating the behavior using SSL options on older OpenSSL versions
that lack SSL_CTX_set_{min,max}_proto_version(). Since we no longer
support OpenSSL 1.0.2, the related code has already been removed.

In OpenSSL 1.1.1 or later, setting the minimum or maximum version to 0
is not equivalent to leaving it unset. Similar to SSL options, which we
avoid overwriting as of commit 00bec0d905 and commit 77c3db2d65 [2],
a system-wide configuration file may define a default protocol version
bounds. Setting the minimum version should not unset the maximum
version, and vice versa.

[1] https://github.com/ruby/openssl/pull/142
[2] https://github.com/ruby/openssl/pull/767

5766386321
2025-02-03 09:46:03 +00:00
Naoto Ono
8cbff4fe45
Add sleep to PTY tests to stabilize flaky failures (#12691) 2025-02-03 16:07:19 +09:00
Benoit Daloze
15e6f13ff7 [ruby/fiddle] Fix Fiddle.last_error on FFI backend and improve test
to work for all
(https://github.com/ruby/fiddle/pull/173)

ef2382a7ef
2025-02-03 10:22:16 +09:00
dependabot[bot]
56c814a8d3 [rubygems/rubygems] Bump the rb-sys group across 2 directories with 1 update
Bumps the rb-sys group with 1 update in the /test/rubygems/test_gem_ext_cargo_builder/custom_name/ext/custom_name_lib directory: [rb-sys](https://github.com/oxidize-rb/rb-sys).
Bumps the rb-sys group with 1 update in the /test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example directory: [rb-sys](https://github.com/oxidize-rb/rb-sys).

Updates `rb-sys` from 0.9.108 to 0.9.110
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.108...v0.9.110)

Updates `rb-sys` from 0.9.108 to 0.9.110
- [Release notes](https://github.com/oxidize-rb/rb-sys/releases)
- [Commits](https://github.com/oxidize-rb/rb-sys/compare/v0.9.108...v0.9.110)

---
updated-dependencies:
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rb-sys
- dependency-name: rb-sys
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: rb-sys
...

Signed-off-by: dependabot[bot] <support@github.com>

a92f814b53
2025-02-03 10:05:36 +09:00
David Rodríguez
c0688c21fe [rubygems/rubygems] Raise a simpler error when RubyGems fails to activate a dependency
If you force uninstall a dependency but leave other gems depending on
it, those gems will fail to be activated.

In that case, RubyGems prints a rather complicated error:

```
$ rails --version
/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1413:in 'block in Gem::Specification#activate_dependencies': Could not find 'activesupport' (= 8.0.1) among 478 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/deivid/.local/share/gem/ruby/3.4.0:/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/gems/3.4.0' at: /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/specifications/railties-8.0.1.gemspec, execute `gem env` for more information
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1399:in 'Array#each'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1399:in 'Gem::Specification#activate_dependencies'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1381:in 'Gem::Specification#activate'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:283:in 'block in Gem.activate_bin_path'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Thread::Mutex#synchronize'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Gem.activate_bin_path'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/bin/rails:25:in '<main>'
/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/dependency.rb:303:in 'Gem::Dependency#to_specs': Could not find 'activesupport' (= 8.0.1) - did find: [activesupport-7.1.3,activesupport-7.0.8.7] (Gem::MissingSpecVersionError)
Checked in 'GEM_PATH=/Users/deivid/.local/share/gem/ruby/3.4.0:/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/gems/3.4.0' , execute `gem env` for more information
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1411:in 'block in Gem::Specification#activate_dependencies'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1399:in 'Array#each'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1399:in 'Gem::Specification#activate_dependencies'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1381:in 'Gem::Specification#activate'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:283:in 'block in Gem.activate_bin_path'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Thread::Mutex#synchronize'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Gem.activate_bin_path'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/bin/rails:25:in '<main>'
```

With this commit, the error becomes a bit simpler to parse:

```
$ rails --version
/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1421:in 'block in Gem::Specification#activate_dependencies': Could not find 'activesupport' (= 8.0.1) among 478 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/deivid/.local/share/gem/ruby/3.4.0:/Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/gems/3.4.0' at: /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/gems/3.4.0/specifications/railties-8.0.1.gemspec, execute `gem env` for more information
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1407:in 'Array#each'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1407:in 'Gem::Specification#activate_dependencies'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems/specification.rb:1389:in 'Gem::Specification#activate'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:283:in 'block in Gem.activate_bin_path'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Thread::Mutex#synchronize'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/lib/ruby/site_ruby/3.4.0/rubygems.rb:282:in 'Gem.activate_bin_path'
	from /Users/deivid/.asdf/installs/ruby/3.4.1/bin/rails:25:in '<main>'
```

And also, we reduce exception based control flow in our code.

7e48c49f2d
2025-02-03 10:05:34 +09:00