91898 Commits

Author SHA1 Message Date
Takashi Kokubun
c750856367 Fix -Wreturn-type
../variable.c: In function ‘iterate_over_shapes_with_callback’:
../variable.c:2189:1: warning: control reaches end of non-void function [-Wreturn-type]
 2189 | }
      | ^
2025-05-08 10:46:09 -07:00
Peter Zhu
c18bedcdbb Remove dependency on debug_counter.h when BUILDING_MODULAR_GC
This allows the default GC to not need debug_counter.h when building as a
modular GC.
2025-05-08 10:36:27 -04:00
Peter Zhu
3f5080e767 Stop checking for USE_DEBUG_COUNTER in default.c
We don't need to check for USE_DEBUG_COUNTER because the code is no-op
if USE_DEBUG_COUNTER is not enabled.
2025-05-08 10:36:27 -04:00
Burdette Lamar
46a8240884
[DOC] Tweaks for String#-@ 2025-05-08 10:31:47 -04:00
Max Bernstein
5e53484994
ZJIT: Temporarily revert path compression
For reasons I don't understand yet, this causes an issue when trying to
boot yjit-bench. Temporarily revert it.
2025-05-08 21:22:44 +09:00
Nobuyoshi Nakada
f3006c26de Add depend files under ext/-test- 2025-05-08 18:20:51 +09:00
Ellen Marie Dash
a41eed99c0
[rubygems/rubygems] Update TarWriter test to store mtime in a variable
https://github.com/rubygems/rubygems/commit/0e2cec3fa3
2025-05-08 18:03:04 +09:00
Yusuke Nakamura
819ecd115d
[rubygems/rubygems] Add mtime to Gem::Package::TarWriter#add_file argument
Since 9e21dd9, Gem::Package::TarWriter#add_file adds the file to
the tar with Gem.source_date_epoch for its mtime.
This behavior breaks the code depending on the previous add_file
behavior.
Therefore, add_file accepts mtime as an argument, and uses
Gem.source_date_epoch if not specified.

https://github.com/rubygems/rubygems/commit/7020ea98a0
2025-05-08 18:03:04 +09:00
Charles Oliver Nutter
8685a81e6a
[ruby/strscan] jruby: Check if len++ walked off the end
(https://github.com/ruby/strscan/pull/153)

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

CRuby can walk off the end because there's always a null byte. In JRuby,
the byte array is often (usually?) the exact size of the string. So we
need to check if len++ walked off the end.

This code was ported from a version by @byroot in
https://github.com/ruby/strscan/pull/127 but I missed adding this check
due to a lack of tests. A test is included for both "-" and "+" parsing.

https://github.com/ruby/strscan/commit/1abe4ca556
2025-05-08 18:03:04 +09:00
Charles Oliver Nutter
5a0306f9c1
[ruby/strscan] jruby: Pass end index to byteListToInum
(https://github.com/ruby/strscan/pull/150)

These parse methods take begin and end indices, not begin and length. A
test is included.

Fixes https://github.com/jruby/jruby/issues/8823

https://github.com/ruby/strscan/commit/9690e39e73
2025-05-08 18:03:04 +09:00
Nobuyoshi Nakada
61b6f226e8
[ruby/json] Constify static data in fpconv.c
https://github.com/ruby/json/commit/3b605d9b1e
2025-05-08 18:03:04 +09:00
Jean Boussier
1f2a9dc2a9
[ruby/psych] Refine Ruby 3.5 Set support.
Use feature testing to detect native Set,
and don't rely on `Set#to_h` which wasn't intended
as a public method.

https://github.com/ruby/psych/commit/d58cff11af
2025-05-08 18:03:04 +09:00
Jean Boussier
49b4e0350d Make test/ruby/test_env.rb#test_delete_if_in_ractor easier to debug 2025-05-08 09:50:45 +02:00
Jean Boussier
71baa6943b variable.c: Fix compilation warnings
```
variable.c: In function ‘iterate_over_shapes_with_callback’:
variable.c:2188:1: warning: control reaches end of non-void function [-Wreturn-type]
	 2188 | }
	      | ^
variable.c: In function ‘rb_field_get’:
variable.c:1322:43: warning: ‘fields_tbl’ may be used uninitialized [-Wmaybe-uninitialized]
	 1322 |         return fields_tbl->as.shape.fields[attr_index];
	      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
variable.c:1319:32: note: ‘fields_tbl’ was declared here
	 1319 |         struct gen_fields_tbl *fields_tbl;
	      |
```
2025-05-08 09:50:45 +02:00
Jean Boussier
cf9046c00b Refactor id_to_obj_tbl compaction
Use `st_foreach_with_replace` rather than to call `st_insert`
from inside `st_foreach`, this saves from having to disable GC.

Co-Authored-By: Peter Zhu <peter@peterzhu.ca>
2025-05-08 07:58:05 +02:00
Jean Boussier
2d1241ba97 Get rid of RB_GC_VM_ID_TO_OBJ_TABLE_KEYS 2025-05-08 07:58:05 +02:00
Jean Boussier
f48e45d1e9 Move object_id in object fields.
And get rid of the `obj_to_id_tbl`

It's no longer needed, the `object_id` is now stored inline
in the object alongside instance variables.

We still need the inverse table in case `_id2ref` is invoked, but
we lazily build it by walking the heap if that happens.

The `object_id` concern is also no longer a GC implementation
concern, but a generic implementation.

Co-Authored-By: Matt Valentine-House <matt@eightbitraptor.com>
2025-05-08 07:58:05 +02:00
Jean Boussier
d34c150547 shape.c: refactor frozen shape to no longer be final
This opens the door to store more informations in shapes, such
as the `object_id` or object address in case it has been observed
and the object has to be moved.
2025-05-08 07:58:05 +02:00
Jean Boussier
6c9b3ac232 Refactor OBJ_TOO_COMPLEX_SHAPE_ID to not be referenced outside shape.h
Also refactor checks for `->type == SHAPE_OBJ_TOO_COMPLEX`.
2025-05-08 07:58:05 +02:00
Jean Boussier
0ea210d1ea Rename ivptr -> fields, next_iv_index -> next_field_index
Ivars will longer be the only thing stored inline
via shapes, so keeping the `iv_index` and `ivptr` names
would be confusing.

Instance variables won't be the only thing stored inline
via shapes, so keeping the `ivptr` name would be confusing.

`field` encompass anything that can be stored in a VALUE array.

Similarly, `gen_ivtbl` becomes `gen_fields_tbl`.
2025-05-08 07:58:05 +02:00
Hiroshi SHIBATA
4e30b77b90 Added depend file for test/-ext-/econv/test_append.rb
ce51ef30df broke
ext/-test-/econv/append.o. We should rebuild that object file when dependencies are updated.
2025-05-08 12:34:22 +09:00
Peter Zhu
3e94b5f9c0 Remove dependence on internal/hash.h for default GC 2025-05-07 11:47:13 -04:00
Hiroshi SHIBATA
d6d63b278a
Enabled debug mode for CodeQL 2025-05-07 07:32:18 +09:00
Étienne Barrié
cb772247e7 Improve correctness contention for allocated object counts
Currently the count of allocated object for a heap is incremented
without regards to parallelism which leads to incorrect counts.

By maintaining a local counter in the ractor newobj cache, and only
syncing atomically with some granularity, we can improve the correctness
without increasing contention.

The allocated object count is also synced when the ractor is freed.

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2025-05-06 19:13:59 +02:00
Max Bernstein
925da36876 Parse topn, opt_length, opt_size into HIR 2025-05-07 00:11:44 +09:00
Takashi Kokubun
cbf9c088f8
YJIT: End the block after OPTIMIZE_METHOD_TYPE_CALL (#13245) 2025-05-05 13:35:28 -07:00
Alan Wu
4621feb677 ZJIT: Use 2024 edition for rustc-only release builds 2025-05-06 01:04:59 +09:00
Jean Boussier
e042e10644 vm_dump.c: avoid USE_MN_THREADS is not defined warning 2025-05-05 15:55:42 +02:00
Jean Boussier
3a2e56e685 Fix USE_MN_THREADS=0 builds on macOS
This was recently broken.
2025-05-05 15:34:32 +02:00
Jean Boussier
a3af4e905f Make rb_shape.capacity an attr_index_t 2025-05-05 14:44:49 +02:00
Jean Boussier
bbea71fafb variable.c: Fix too_complex shape initialization
`SHAPE_OBJ_TOO_COMPLEX` is a `shape_type` not a `shape_id_t`.
2025-05-05 14:44:49 +02:00
Jean Boussier
53ae558042 Improve style consistency of rb_shape_t * 2025-05-05 14:44:49 +02:00
Nobuyoshi Nakada
5b1a61e29c [ruby/digest] stringop-overread warning is since GCC 11
https://github.com/ruby/digest/commit/d16853fe8c
2025-05-05 10:20:31 +00:00
Nobuyoshi Nakada
bbf1130f91 Add RBIMPL_ATTR_NONSTRING_ARRAY() macro for GCC 15 2025-05-05 18:25:04 +09:00
Jeremy Evans
ce51ef30df Save one VALUE per embedded RTypedData
This halves the amount of memory used for embedded RTypedData if they
are one VALUE (8 bytes on 64-bit platforms) over the slot size limit.

For Set, on 64-bit it uses an embedded 56-byte struct.  With the
previous implementation, the embedded structs starts at offset 32,
resulting in a total size of 88.  Since that is over the 80 byte
limit, it goes to the next highest bucket, 160 bytes, wasting 72
bytes.  This allows it to fit in a 80 byte bucket, which reduces
the total size for small sets of from 224 bytes (160 bytes
embedded, 64 bytes malloc, 72 bytes wasted in embedding) to 144
bytes (80 bytes embedded, 64 bytes malloc, 0 bytes wasted in
embedding).

Any other embedded RTypedData will see similar advantages if they
are currently one VALUE over the limit.

To implement this, remove the typed_flag from struct RTypedData.
Embed the typed_flag information in the type member, which is
now a tagged pointer using VALUE type, using the bottom low 2 bits
as flags (1 bit for typed flag, the other for the embedded flag).
To get the actual pointer, RTYPEDDATA_TYPE masks out
the low 2 bits and then casts.  That moves the RTypedData data
pointer from offset 32 to offset 24 (on 64-bit).

Vast amount of code in the internals (and probably external C
extensions) expects the following code to work for both RData and
non-embedded RTypedData:

```c
DATA_PTR(obj) = some_pointer;
```

Allow this to work by moving the data pointer in RData between
the dmark and dfree pointers, so it is at the same offset (24
on 64-bit).

Other than these changes to the include files, the only changes
needed were to gc.c, to account for the new struct layouts,
handle setting the low bits in the type member, and to use
RTYPEDDATA_TYPE(obj) instead of RTYPEDDATA(obj)->type.
2025-05-05 09:46:32 +09:00
BurdetteLamar
35918df740 [DOC] Tweaks for String#+ 2025-05-04 17:14:44 -04:00
BurdetteLamar
d2de59798c [DOC] Tweaks for String#* 2025-05-04 17:14:17 -04:00
BurdetteLamar
d71e171464 [DOC] Tweaks for String#% 2025-05-04 17:13:50 -04:00
Nobuyoshi Nakada
ce8f7da49e
[Bug #21304] Reload length and pointer after #hash method
The receiver can be modified during the method calls.
2025-05-04 12:40:33 +00:00
Jeremy Evans
21035c826d Handle mutating of array passed to Set.new during iteration
This avoids a heap-use-after-free.

Fixes [Bug #21306]
2025-05-04 04:10:57 +09:00
Jeremy Evans
be665cf855 Handle mutation of array being merged into set
Check length of array during every iteration, as a #hash method
could truncate the array, resulting in heap-use-after-free.

Fixes [Bug #21305]
2025-05-04 04:10:57 +09:00
Yusuke Endoh
f3246ccebb Fix an ASAN error in Array#difference
[Bug #21303]
2025-05-04 02:20:42 +09:00
Misaki Shioi
2be117a97d
Fix heap-use-after-free in free_fast_fallback_getaddrinfo_entry (#13231)
This change addresses the following ASAN error:

```
==36597==ERROR: AddressSanitizer: heap-use-after-free on address 0x512000396ba8 at pc 0x7fcad5cbad9f bp 0x7fff19739af0 sp 0x7fff19739ae8
  WRITE of size 8 at 0x512000396ba8 thread T0
  [643/756] 36600=optparse/test_summary
      #0 0x7fcad5cbad9e in free_fast_fallback_getaddrinfo_entry /home/runner/work/ruby-dev-builder/ruby-dev-builder/ext/socket/raddrinfo.c:3046:22
      #1 0x7fcad5c9fb48 in fast_fallback_inetsock_cleanup /home/runner/work/ruby-dev-builder/ruby-dev-builder/ext/socket/ipsocket.c:1179:17
      #2 0x7fcadf3b611a in rb_ensure /home/runner/work/ruby-dev-builder/ruby-dev-builder/eval.c:1081:5
      #3 0x7fcad5c9b44b in rsock_init_inetsock /home/runner/work/ruby-dev-builder/ruby-dev-builder/ext/socket/ipsocket.c:1289:20
      #4 0x7fcad5ca22b8 in tcp_init /home/runner/work/ruby-dev-builder/ruby-dev-builder/ext/socket/tcpsocket.c:76:12
      #5 0x7fcadf83ba70 in vm_call0_cfunc_with_frame /home/runner/work/ruby-dev-builder/ruby-dev-builder/./vm_eval.c:164:15
...
```

A `struct fast_fallback_getaddrinfo_shared` is shared between the main thread and two child threads.
This struct contains an array of `fast_fallback_getaddrinfo_entry`.

`fast_fallback_getaddrinfo_entry` and `fast_fallback_getaddrinfo_shared` were freed separately, and if `fast_fallback_getaddrinfo_shared` was freed first and then an attempt was made to free a `fast_fallback_getaddrinfo_entry`, a `heap-use-after-free` could occur.

This change avoids that possibility by separating the deallocation of the addrinfo memory held by `fast_fallback_getaddrinfo_entry` from the access and lifecycle of the `fast_fallback_getaddrinfo_entry` itself.
2025-05-03 21:39:57 +09:00
John Hawthorn
36c64b3be8 Also prefer FL_TEST_RAW in gc.c
Similar to 4a040eeb0d880b67a5005cce382122fd5b629b99, I noticed the test
for FL_FINALIZE checking FL_ABLE in a profile, and we shouldn't need to
do that here.
2025-05-02 14:28:25 -07:00
Max Bernstein
23000c7339
ZJIT: Parse opt_newarray_send into HIR (#13242) 2025-05-02 20:01:22 +00:00
Yuta Saito
186022d13f wasm: increase the default Asyncify buffer size
We will need more Asyncify space for the upcoming namespace changes
as it will introduce more local variables and conditional jumps in
asyncify'd functions.
2025-05-03 01:36:13 +08:00
Alan Wu
33909a1c69 YJIT: ZJIT: Share identical glue functions
Working towards having YJIT and ZJIT in the same build, we need to
deduplicate some glue code that would otherwise cause name collision.
Add jit.c for this and build it for YJIT and ZJIT builds. Update bindgen
to look at jit.c; some shuffling of functions in the output, but the set
of functions shouldn't have changed.
2025-05-02 23:47:57 +09:00
Alan Wu
aafd10616d Add an include guard for insns_info.inc
The JIT bindgens need this.
2025-05-02 23:47:57 +09:00
Alan Wu
dd0e0eb4ac Delete always true assert [ci skip] 2025-05-02 21:06:11 +09:00
Nobuyoshi Nakada
85198262a3 [ruby/digest] Suppress false stringop-overread warning
https://github.com/ruby/digest/commit/0df846e8c1
2025-05-02 09:46:51 +00:00