91765 Commits

Author SHA1 Message Date
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
Nobuyoshi Nakada
2e3f81838c
Align styles [ci skip] 2025-05-15 17:48:40 +09:00
Nobuyoshi Nakada
427ede2dde
CI: Fix revision.h on Windows
- Quote % inside `if` block
- Use short branch name
2025-05-15 17:25:56 +09:00
Samuel Williams
87261c2d95
Ensure that forked process do not see invalid blocking operations. (#13343) 2025-05-15 15:50:15 +09:00
Nobuyoshi Nakada
49b306ecb9 [Bug #21333] Prohibit hash modification inside Hash#update block 2025-05-15 15:39:15 +09:00
Nobuyoshi Nakada
a5da3682ef
CI: Refine setup on Windows
Get rid of hardcoded paths
2025-05-15 15:08:43 +09:00
Samuel Williams
a4ce8639d9 Add continue-on-error to failed Windows 2025 build. 2025-05-15 14:51:02 +09:00
Burdette Lamar
7afee53fa0
[DOC] Tweaks for String#<< (#13306) 2025-05-14 15:24:30 -04:00
Burdette Lamar
10e8119cff
[DOC] Tweaks for String#== (#13323) 2025-05-14 15:24:19 -04:00
Jean Boussier
76ec41bf3d Bump ABI_VERSION
`struct RTypedData` was changed significantly in https://github.com/ruby/ruby/pull/13190
which breaks many extensions.

Bumping the ABI version might save some people from needlessly
investigating crashes.
2025-05-14 21:01:32 +02:00
Burdette Lamar
b00a339603
[DOC] Tweaks for String#[] (#13335) 2025-05-14 14:34:09 -04:00
BurdetteLamar
1f72512b03 [DOC] Tweaks for String#[]= 2025-05-14 14:33:40 -04:00
git
ee7dcef0f6 Update default gems list at 57f8dde0f2228dbc67503403d740a7 [ci skip] 2025-05-14 17:11:57 +00:00
Takashi Kokubun
57f8dde0f2 [ruby/erb] Version 5.0.1
https://github.com/ruby/erb/commit/42f389dc45
2025-05-14 17:10:04 +00:00
Takashi Kokubun
ef0e4406c8 Revert "Set WASMTIME_BACKTRACE_DETAILS=1 for WASM basictest"
This reverts commit cb88edf0bfdc2ce6bfbe3b4e0463a4c2dc5d2230.

It didn't help. You need to go to a different repository (ruby/ruby.wasm)
to see meaningful backtraces.
https://github.com/ruby/ruby.wasm/actions/runs/15000135135/job/42144675968#step:16:176
2025-05-14 10:06:28 -07:00
Alan Wu
1825ae4567 ZJIT: Add CI runs for building with YJIT 2025-05-15 00:39:03 +09:00
Alan Wu
92b218fbc3 YJIT: ZJIT: Allow both JITs in the same build
This commit allows building YJIT and ZJIT simultaneously, a "combo
build". Previously, `./configure --enable-yjit --enable-zjit` failed. At
runtime, though, only one of the two can be enabled at a time.

Add a root Cargo workspace that contains both the yjit and zjit crate.
The common Rust build integration mechanisms are factored out into
defs/jit.mk.

Combo YJIT+ZJIT dev builds are supported; if either JIT uses
`--enable-*=dev`, both of them are built in dev mode.

The combo build requires Cargo, but building one JIT at a time with only
rustc in release build remains supported.
2025-05-15 00:39:03 +09:00
Jean Boussier
b5575a80bc Reduce Object#object_id contention.
If the object isn't shareable and already has a object_id
we can access it without a lock.

If we need to generate an ID, we may need to lock to find
the child shape.

We also generate the next `object_id` using atomics.
2025-05-14 14:41:46 +02:00
Alan Wu
920dc0fe3a ZJIT: Split long use line and add a module doc. 2025-05-14 20:13:26 +09:00
Alan Wu
4eff1727e3 ZJIT: More tests for parsing param forms 2025-05-14 20:13:26 +09:00
Alan Wu
37d6de5331 ZJIT: Infer ArrayExact for the rest parameter
The rest parameter is always a rb_cArray, even when anonymous. (This is
different from kw_rest, which can be nil.)
2025-05-14 20:13:26 +09:00
Alan Wu
767e8e165a ZJIT: Fix rest parameter not parsed into a BB parameter
Use total parameter size instead of lead parameter size when parsing
iseq into hir. Also, copy over IntoUsize for compile-time checked
u32->usize cast.
2025-05-14 20:13:26 +09:00
Alan Wu
074dce8370 ZJIT: Add IntoUsize, ported from YJIT 2025-05-14 20:13:26 +09:00
Jean Boussier
f9c3feccf4 Rename id_to_obj_tbl -> id2ref_tbl
As well as associated functions, this should make it more obvious
what the purpose is.
2025-05-14 11:41:14 +02:00
Jean Boussier
9400119702 Fix object_id for classes and modules in namespace context
Given classes and modules have a different set of fields in every
namespace, we can't store the object_id in fields for them.

Given that some space was freed in `RClass` we can store it there
instead.
2025-05-14 10:26:48 +02:00
Jean Boussier
130d6aaef2 Reclaim one VALUE from rb_classext_t by shrinking super_classdepth
By making `super_classdepth` `uint16_t`, classes and modules can
now fit in 160B slots again.

The downside of course is that before `super_classdepth` was large
enough we never had to care about overflow, as you couldn't
realistically create enough classes to ever go over it.

With this change, while it is stupid, you could realistically
create an ancestor chain containing 65k classes and modules.
2025-05-14 10:17:03 +02:00
Hiroshi SHIBATA
f855bcc6b2
Applied rake vendor:install 2025-05-14 15:13:45 +09:00
Hiroshi SHIBATA
cc3d304b47
[rubygems/rubygems] Try cgi-0.5.0.beta2
https://github.com/rubygems/rubygems/commit/5d5e37bf23
2025-05-14 15:13:45 +09:00
David Rodríguez
a89460a8a0
[rubygems/rubygems] Reenable skipped specs in truffleruby since they should be fixed
https://github.com/rubygems/rubygems/commit/a7cbec95c1
2025-05-14 15:13:45 +09:00
Hiroshi SHIBATA
52d72979ae
[rubygems/rubygems] Update vendored version and patch for net-http and net-http-persistent
https://github.com/rubygems/rubygems/commit/b9a4722d5e
2025-05-14 15:13:45 +09:00
Hiroshi SHIBATA
a7af85a7bd Use gh cache 2025-05-14 15:08:52 +09:00
Hiroshi SHIBATA
af74130544 Purge the oldest TRAP cache with gh actions-cache cli 2025-05-14 15:08:52 +09:00
Hiroshi SHIBATA
3b459b5ab6 Disabled TRAP cache of CodeQL 2025-05-14 15:08:52 +09:00
John Hawthorn
86f5cec782 Add misc/tsan_suppressions.txt 2025-05-13 20:09:30 -07:00