91898 Commits

Author SHA1 Message Date
Jean Boussier
83d636f2d0 Free shapes last
[Bug #21352]

`rb_objspace_free_objects` may need to check objects shapes
to know how to free them.
2025-05-19 15:06:08 +02:00
Kazuhiro NISHIYAMA
40c957ba21
Fix a typo and capitalize a character 2025-05-19 13:27:50 +09:00
Jean Boussier
4759550967
[ruby/json] Remove some unnecessary top level constant lookups
https://github.com/ruby/json/commit/7c03ffc3e0
2025-05-19 11:19:17 +09:00
GrantBirki
e4a44b1f2a
[ruby/json] remove redundant self.
https://github.com/ruby/json/commit/c060943d04
2025-05-19 11:19:17 +09:00
GrantBirki
9b25023fe4
[ruby/json] use . over :: for consistency
https://github.com/ruby/json/commit/f5c1b8c45d
2025-05-19 11:19:17 +09:00
Grant Birkinbine
dc69bebde7
[ruby/json] Update json_encoding_test.rb
https://github.com/ruby/json/commit/0ac54a8161
2025-05-19 11:19:17 +09:00
Cody Horton
3468811ed1
[ruby/json] fix for pretty_generate throwing wrong number of arguments error
https://github.com/ruby/json/commit/8433571dcf
2025-05-19 11:19:17 +09:00
David Rodríguez
57e4176649
[rubygems/rubygems] Fix test warnings introduced by recent CGI changes
They read like this:

```
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/util.rb:13: warning: method redefined; discarding old rfc1123_date
/opt/hostedtoolcache/Ruby/3.4.3/x64/lib/ruby/3.4.0/cgi/util.rb:225: warning: previous definition of rfc1123_date was here
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/util.rb:34: warning: method redefined; discarding old pretty
/opt/hostedtoolcache/Ruby/3.4.3/x64/lib/ruby/3.4.0/cgi/util.rb:246: warning: previous definition of pretty was here
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/escape.rb:16: warning: method redefined; discarding old escape
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/escape.rb:29: warning: method redefined; discarding old unescape
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/util.rb:13: warning: method redefined; discarding old rfc1123_date
/opt/hostedtoolcache/Ruby/3.4.3/x64/lib/ruby/3.4.0/cgi/util.rb:225: warning: previous definition of rfc1123_date was here
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/util.rb:34: warning: method redefined; discarding old pretty
/opt/hostedtoolcache/Ruby/3.4.3/x64/lib/ruby/3.4.0/cgi/util.rb:246: warning: previous definition of pretty was here
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/escape.rb:16: warning: method redefined; discarding old escape
/home/runner/work/rubygems/rubygems/bundler/tmp/gems/base/ruby/3.4.0/gems/cgi-0.5.0.beta2/lib/cgi/escape.rb:29: warning: method redefined; discarding old unescape
```

The problem is that `rspec` loads `erb` for its configuration, which
loads `cgi/util` from system gems.

Then our tests change the `$LOAD_PATH` to make test gems installed in
tmp visible to `require`, and then they all require `cgi` as a
transitive dependency of `rack-test`, this time from `tmp` gems. This
causes system and test specific copies to be mixed together and these
warnings to be printed, but we have also observed failures in some tests
with errors like

> class variable @@accept_charset of CGI::Util is overtaken by CGI::Escape

This changes should also fix those failures.

The fix is to require all of `rack-test` (including `cgi`) before we
have changed the `$LOAD_PATH`. Because the `$LOAD_PATH` is unchanged,
RubyGems respects the version of `cgi` activated by RSpec, avoiding the
double loads.

https://github.com/rubygems/rubygems/commit/34e75465c6
2025-05-19 11:19:17 +09:00
David Rodríguez
0f867d97ab
Rename a couple of spec files
Generally are "realworld" specs are the ones using VCR cassettes of real
requests. These files don't use that, so I moved them to a different
place.
2025-05-19 11:19:17 +09:00
David Rodríguez
6e8be3a634 [rubygems/rubygems] Test JRuby 10
Necessary changes to get tests passing are:

* Rewrite one "out of memory" error spec to not define a subclass inside
  a RSpec context block. Due to some [JRuby issue], that's failing in
  JRuby 10, so I rewrote the test so that the Bundler process really
  goes OOM and that class definition is not necessary.
* JRuby 10, even if Ruby 3.4-compatible, has not yet adapted backtraces
  to include receivers, so our tests need an special case for JRuby when
  detecting a test method call inside backtraces.
* Warbler test is upgraded to use JRuby 10. Getting it to pass needs [a
  PR] to warbler, so our test is temporarily pointing to that PR.

[JRuby issue]: https://github.com/jruby/jruby/issues/8838
[a PR]: https://github.com/jruby/warbler/pull/557

https://github.com/rubygems/rubygems/commit/edec85d4c3
2025-05-19 11:15:33 +09:00
David Rodríguez
bfab76abe6 [rubygems/rubygems] Normalize platforms in warbler lockfile
https://github.com/rubygems/rubygems/commit/c7c50343bb
2025-05-19 11:15:31 +09:00
Vít Ondruch
0dfe427cba [rubygems/rubygems] Fix typo "shippped" => "shipped"
https://github.com/rubygems/rubygems/commit/1762d18d7b
2025-05-19 11:15:31 +09:00
David Rodríguez
aea603615f [rubygems/rubygems] Missing tweak
https://github.com/rubygems/rubygems/commit/407c1cbcfe
2025-05-19 11:15:30 +09:00
Samuel Giddins
4be199e435 [rubygems/rubygems] Simplify Gem::Platform#initialize
Based on PR feedback

Signed-off-by: Samuel Giddins <segiddins@segiddins.me>

https://github.com/rubygems/rubygems/commit/562d7aa087
2025-05-19 11:15:29 +09:00
Samuel Giddins
8f61e17556 [rubygems/rubygems] RuboCop
Signed-off-by: Samuel Giddins <segiddins@segiddins.me>

https://github.com/rubygems/rubygems/commit/768784910b
2025-05-19 11:15:29 +09:00
Samuel Giddins
eb48418b40 [rubygems/rubygems] Ensure that Gem::Platform parses strings to a fix point
The issue was that the property that

```ruby
platform = Gem::Platform.new $string
platform == Gem::Platform.new(platform.to_s)
```

was not always true.

This property (of acchieving a fix point) is important,
since `Gem::Platform` gets serialized to a string and
then deserialized back to a `Gem::Platform` object.
If it doesn't deserialize to the same object, then
different platforms are used for the initial serialization
than subsequent runs.

I used https://github.com/segiddins/Scratch/blob/main/2025/03/rubygems-platform.rb
to find the failing cases and then fixed them.
With this patch, the prop check test now passes.

https://github.com/rubygems/rubygems/commit/313fb4bcec
2025-05-19 11:15:28 +09:00
Hiroshi SHIBATA
72387ebd0e
Fix typos: misspell -w -error -source=text namespace.c 2025-05-19 09:46:03 +09:00
Daisuke Aritomo
aa0f689bf4 [ruby/net-http] Freeze some constants to improve Ractor compatibility
Freeze `Net::HTTP::SSL_IVNAMES`, `Net::HTTPResponse::CODE_CLASS_TO_OBJ`
and `Net::HTTPResponse::CODE_TO_OBJ` to improve Ractor compatibility.

This change allows the following code to work:

    Ractor.new {
      uri = URI.parse('http://example.com')
      http = Net::HTTP.new(uri.host, uri.port)
      http.open_timeout = nil
      http.read_timeout = nil
      http.get('/index.html')
    }

https://github.com/ruby/net-http/commit/9f0f5e4b4d
2025-05-17 00:42:12 +00:00
Jean Boussier
22c09135a8 rb_copy_generic_ivar: reset shape_id when no ivar are present 2025-05-16 20:16:52 +02:00
Jean Boussier
1e33a451bb gc: Execute run_final with the lock held
The finalizer table can't be read nor modified without the VM lock.
2025-05-16 20:16:52 +02:00
Jean Boussier
ec8900e3eb rb_gc_impl_copy_finalizer: generate a new object id
Fix a regression introduced by: https://github.com/ruby/ruby/pull/13155
2025-05-16 20:16:52 +02:00
Jean Boussier
a294427017 Add missing lock to rb_gc_impl_copy_finalizer 2025-05-16 20:16:52 +02:00
Max Bernstein
d9248856d2
ZJIT: Create more ergonomic type profiling API (#13339) 2025-05-16 10:50:48 -07:00
Daniel Colson
eead83160b
Prevent enabling yjit when zjit enabled (GH-13358)
`ruby --yjit --zjit` already warns and exits, but it was still possible
to enable both with `ruby --zjit -e 'RubyVM:YJIT.enable`.

This commit prevents that with a warning and an early return. (We could
also exit, but that seems a bit unfriendly once we're already running
the program.)

Co-authored-by: ywenc <ywenc@github.com>
2025-05-16 17:31:43 +00:00
Burdette Lamar
cc90adb68d
[DOC] Tweaks for String#append_as_bytes 2025-05-16 12:50:55 -04:00
BurdetteLamar
a188249616 [DOC] Tweaks for String#b 2025-05-16 12:47:17 -04:00
BurdetteLamar
1f09c9fa14 [DOC] Tweaks for String#ascii_only? 2025-05-16 12:46:56 -04:00
Nick Dower
c5c252c067 Add a test case for it in a regex.
Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
2025-05-17 00:17:21 +09:00
Nick Dower
4921845b61 [Bug #21313] Handle it in rescue and ensure blocks.
The following is crashing for me:

```shell
ruby --yjit --yjit-call-threshold=1 -e '1.tap { raise rescue p it }'

ruby: YJIT has panicked. More info to follow...
thread '<unnamed>' panicked at ./yjit/src/codegen.rs:2402:14:
...
```

It seems `it` sometimes points to the wrong value:

```shell
ruby -e '1.tap { raise rescue p it }'
false

ruby -e '1.tap { begin; raise; ensure; p it; end } rescue nil'
false
```

But only when `$!` is set:

```shell
ruby -e '1.tap { begin; nil; ensure; p it; end }'
1

ruby -e '1.tap { begin; nil; rescue; ensure; p it; end }'
1

ruby -e '1.tap { begin; raise; rescue; ensure; p it; end }'
1
```
2025-05-17 00:17:21 +09:00
Nobuyoshi Nakada
097d742a1e [Bug #20009] Support marshaling non-ASCII name class/module 2025-05-16 21:22:33 +09:00
Max Bernstein
5e01c0e4e2 ZJIT: Remove unnecessary cloning 2025-05-16 21:08:01 +09:00
Nobuyoshi Nakada
9cec38c160
"binary" is not valid encoding name in Emacs 2025-05-16 20:04:34 +09:00
Samuel Williams
a0fe0095ab
Don't enumerate io->blocking_operations if fork generation is different. (#13359) 2025-05-16 14:14:23 +09:00
Hiroya Fujinami
35000ac2ed
Prevent double free for too big repetition quantifiers (#13332)
Prevent double free for too big repetition quantifiers

The previous implementation calls `free(node)` twice (on parsing and compiling a
regexp) when it has an error, so it leads to a double-free issue. This
commit enforces `free(node)` once by introducing a temporal pointer to hold
parsing nodes.
2025-05-16 10:14:26 +09:00
Max Bernstein
6b10d40157 ZJIT: Bail out of recursive compilation if we can't compile callee
Right now we just crash if we can't compile an ISEQ for any reason
(unimplemented in HIR, unimplemented in codegen, ...) and this fixes
that by bailing out.
2025-05-15 15:31:02 -07:00
John Hawthorn
d67d169aea Use atomics for system_working global
Although it almost certainly works in this case, volatile is best not
used for multi-threaded code. Using atomics instead avoids warnings from
TSan.

This also simplifies some logic, as system_working was previously only
ever assigned to 1, so --system_working <= 0 should always return true
(unless it underflowed).
2025-05-15 15:18:10 -07:00
John Hawthorn
d845da05e8 Force reset running time in timer interrupt
Co-authored-by: Ivo Anjo <ivo.anjo@datadoghq.com>
Co-authored-by: Luke Gruber <luke.gru@gmail.com>
2025-05-15 14:44:26 -07:00
Aaron Patterson
55c9c75b47 Maintain same behavior regardless of tracepoint state
Always use opt_new behavior regardless of tracepoint state.
2025-05-15 14:19:48 -07:00
Peter Zhu
04f538c144 Remove dependency on sanitizers.h in default.c when BUILDING_MODULAR_GC 2025-05-15 14:13:53 -04:00
Kazuki Yamaguchi
06a56a7ffc [ruby/openssl] ssl: fix potential memory leak in SSLContext#setup
If SSL_CTX_add_extra_chain_cert() fails, the refcount of x509 must be
handled by the caller. This should only occur due to a malloc failure
inside the function.

https://github.com/ruby/openssl/commit/80bcf727dc
2025-05-15 16:51:15 +00:00
Kazuki Yamaguchi
b43c7cf8c4 [ruby/openssl] cipher: remove Cipher#encrypt(password, iv) form
OpenSSL::Cipher#encrypt and #decrypt have long supported a hidden
feature to derive a key and an IV from the String argument, but in an
inappropriate way.

This feature is undocumented, untested, and has been deprecated since
commit https://github.com/ruby/ruby/commit/0dc43217b189 on 2004-06-30,
which started printing a non-verbose warning. More than 20 years later,
it must be safe to remove it entirely.

The deprecated usage:

	# `password` is a String, `iv` is either a String or nil
	cipher = OpenSSL::Cipher.new("aes-256-cbc")
	cipher.encrypt(password, iv)
	p cipher.update("data") << cipher.final

was equivalent to:

	cipher = OpenSSL::Cipher.new("aes-256-cbc")
	cipher.encrypt

	iv ||= "OpenSSL for Ruby rulez!"
	key = ((cipher.key_len + 15) / 16).times.inject([""]) { |ary, _|
	  ary << OpenSSL::Digest.digest("MD5", ary.last + password + iv[0, 8].ljust(8, "\0"))
	}.join
	cipher.key = key[...cipher.key_len]
	cipher.iv = iv[...cipher.iv_len].ljust(cipher.iv_len, "\0")
	p cipher.update("data") << cipher.final

https://github.com/ruby/openssl/commit/e46d992ea1
2025-05-15 16:50:25 +00:00
Samuel Chiang
0b9644c252 [ruby/openssl] AWS-LC has support for parsing ber constructed strings now
https://github.com/ruby/openssl/commit/cdfc08db50
2025-05-15 16:40:42 +00:00
git
b2ab1b0409 Update bundled gems list as of 2025-05-15 2025-05-15 15:21:46 +00:00
Burdette Lamar
4fc5047af8
[DOC] Tweaks for String#=~ (#13325) 2025-05-15 11:18:49 -04:00
Kazuki Tsujimoto
c3eb406876
Update power_assert for opt_new
https://bugs.ruby-lang.org/issues/21298#note-5
2025-05-16 00:05:42 +09:00
Jean Boussier
31ba881684 Disable GC when building id2ref table
Building that table will likely malloc several time which
can trigger GC and cause race condition by freeing objects
that were just added to the table.

Disabling GC to prevent the race condition isn't elegant,
but iven this is a deprecated callpath that is executed at
most once per process, it seems acceptable.
2025-05-15 16:29:45 +02:00
Jean Boussier
60ffb714d2 Ensure shape_id is never used on T_IMEMO
It doesn't make sense to set ivars or anything shape
related on a T_IMEMO.

Co-Authored-By: John Hawthorn <john@hawthorn.email>
2025-05-15 16:06:52 +02:00
Jean Boussier
ed632cd0ba Add missing lock in rb_gc_impl_undefine_finalizer
The table is global so accesses must be synchronized.
2025-05-15 13:32:08 +02:00
Jean Boussier
3d1b8e7298 newobj_fill: don't assume RBasic size
The previous implementation assumed `RBasic` size is `2 * sizeof(VALUE)`,
might as well not make assumption and use a proper `sizeof`.

Co-Authored-By: John Hawthorn <john@hawthorn.email>
2025-05-15 13:26:26 +02:00
Jean Boussier
186e60cb68 YJIT: handle opt_aset_with
```
 # frozen_string_ltieral: true
hash["literal"] = value
```
2025-05-15 11:56:24 +02:00