Commit graph

91620 commits

Author SHA1 Message Date
Satoshi Tagomori
382645d440 namespace on read 2025-05-11 23:32:50 +09:00
Hiroshi SHIBATA
49742414f6 Revert "Fix redefinition of clock_gettime and clock_getres"
This reverts commit 585598623d.

This broke Windows CIs

```
linking miniruby.exe
   Creating library miniruby.lib and object miniruby.exp
process.obj : error LNK2019: unresolved external symbol clock_gettime referenced in function rb_clock_gettime
random.obj : error LNK2001: unresolved external symbol clock_gettime
thread.obj : error LNK2001: unresolved external symbol clock_gettime
time.obj : error LNK2001: unresolved external symbol clock_gettime
process.obj : error LNK2019: unresolved external symbol clock_getres referenced in function rb_clock_getres
miniruby.exe : fatal error LNK1120: 2 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64\cl.EXE"' : return code '0x2'
```
2025-05-11 12:09:26 +09:00
Zopolis4
915d027738 Fix typo (newsString -> new String) 2025-05-11 07:07:10 +09:00
Daisuke Aritomo
98667f82d2 [DOC] Update documentation for ObjectSpace#each_object
Co-authored-by: Benoit Daloze <eregontp@gmail.com>
2025-05-10 19:32:21 +02:00
Daisuke Aritomo
29b3d683fb [DOC] Make clear that current behavior is not ideal 2025-05-10 19:32:21 +02:00
Daisuke Aritomo
a51b4a86fc [DOC] ObjectSpace#each_object behavior in multi-Ractor mode
This behavior of ObjectSpace#each_object has been around since Ruby 3.0
when Ractors were first introduced, but was never documented and has
caused some amount of confusion:

https://bugs.ruby-lang.org/issues/17360
https://bugs.ruby-lang.org/issues/19387
https://bugs.ruby-lang.org/issues/21149
2025-05-10 19:32:21 +02:00
Jean Boussier
6dd7a7bb41 Refactor rb_obj_field_get to handle complex shapes
This allow to get or set fields without having to worry about the
shape type.
2025-05-10 16:55:22 +02:00
Jean Boussier
d9502a8386 Rename rb_field_get -> rb_obj_field_get
To be consistent with `rb_obj_field_set`.
2025-05-10 15:39:33 +02:00
Nobuyoshi Nakada
585598623d
Fix redefinition of clock_gettime and clock_getres
winpthreads-git 12.0.0.r720 provides `clock_gettime` and
`clock_getres` as inline functions.
2025-05-10 18:26:09 +09:00
Benoit Daloze
7add6b2ac3 ruby/spec has a minimum of Ruby 3.2 now 2025-05-10 10:29:48 +02:00
git
3c37d6ffcf Update bundled gems list as of 2025-05-09 2025-05-10 06:59:40 +00:00
Nobuyoshi Nakada
c75202c57e
[Feature #15408] Fix up _id2ref_spec.rb 2025-05-10 15:41:30 +09:00
John Hawthorn
3306d7d2f9 Only clear Ractor cache in child
This avoids a race condition where we were clearing the cache from
another ractor while it was in use. Oops!

Fixes this failure http://ci.rvm.jp/results/master@oci-aarch64/5750416
2025-05-09 16:15:54 -07:00
git
87b621bd5b Update default gems list at 58c008e68f [ci skip] 2025-05-09 22:13:51 +00:00
Aaron Patterson
58c008e68f [ruby/psych] Bump version for release
dbf9e36583
2025-05-09 22:12:47 +00:00
Benoit Daloze
4a2f489ca6 Fix rb_range_beg_len() and rb_arithmetic_sequence_beg_len_step() spec
* The begp, lenp and stepp might not be written to, so they need default values.
2025-05-09 23:22:15 +02:00
Benoit Daloze
2a9236366d Try removing building C API specs in CRuby makefiles entirely
* Since it does not work when using some configure options such as:
  .../configure --with-ext=-test-/cxxanyargs,+ --enable-shared
  as the CI does.
* It also duplicates the logic of spec/ruby/optional/capi/spec_helper.rb incorrectly.
  ruby/spec maintainers have no experience and no interest in dealing with these complicated CRuby build system issues.
  We asked help on the CRuby Slack and nobody helped so far.
2025-05-09 23:22:15 +02:00
Andrew Konchin
29be534fad Try fixing building C API specs with make
* But it doesn't work because there is no .ext/include/ruby/digest.h
  when using .../configure --with-ext=-test-/cxxanyargs,+ --enable-shared
  as the CI does.
2025-05-09 23:22:15 +02:00
Andrew Konchin
78a2ffa000 Fix digest specs when run in CRuby via make test-spec 2025-05-09 23:22:15 +02:00
Andrew Konchin
cb4a441819 Fix formatting in digest_spec.c 2025-05-09 23:22:15 +02:00
Andrew Konchin
269ad29de9 Update to ruby/spec@d8bacef 2025-05-09 23:22:15 +02:00
Jean Boussier
3135eddb4e Refactor FIRST_T_OBJECT_SHAPE_ID to not be used outside shape.c 2025-05-09 20:45:48 +02:00
OrenGitHub
e2f5e233b5 [ruby/psych] exception tests
1e9b79f699
2025-05-09 17:53:18 +00:00
OrenGitHub
42328d4ef4 [ruby/psych] more special cases
b33bf8b060
2025-05-09 17:53:18 +00:00
OrenGitHub
451e1dcf31 [ruby/psych] duplicate more tests
a3be6429bf
2025-05-09 17:53:17 +00:00
OrenGitHub
ae299cc9cd [ruby/psych] add first test for safe load stream
336553b412
2025-05-09 17:53:17 +00:00
OrenGitHub
f0e2a41d4b [ruby/psych] fixed bugs from testing
e954f96639
2025-05-09 17:53:17 +00:00
OrenGitHub
d69319304f [ruby/psych] Add safe version for load_stream
30a2a5ee94
2025-05-09 17:53:17 +00:00
Peter Zhu
011982ef83 Fix warnings in tests for ObjectSpace._id2ref
There's a lot of warnings when running test_objectspace.rb because of
ObjectSpace._id2ref. For example:

    test_objectspace.rb:19: warning: ObjectSpace._id2ref is deprecated
2025-05-09 12:43:08 -04:00
Takashi Kokubun
102063f964 ZJIT: Fix a splitting condition for LHS 2025-05-09 09:32:40 -07:00
Peter Zhu
f30f0f0a22 Fix crash when instantiating classes in Ractors
[Bug #18119]

When we create classes, it pushes the class to the subclass list of the
superclass. This access needs to be synchronized because multiple Ractors
may be creating classes with the same superclass, which would cause race
conditions and cause the linked list to be corrupted.

For example, we can reproduce with this script crashing:

    workers = (0...8).map do
      Ractor.new do
        loop do
          100.times.map { Class.new }
          Ractor.yield nil
        end
      end
    end

    100.times { Ractor.select(*workers) }

With ASAN enabled, we can see that there are use-after-free errors:

    ==176013==ERROR: AddressSanitizer: heap-use-after-free on address 0x5030000974f0 at pc 0x62f9e56f892d bp 0x7a503f1ffd90 sp 0x7a503f1ffd88
    WRITE of size 8 at 0x5030000974f0 thread T4
        #0 0x62f9e56f892c in rb_class_remove_from_super_subclasses class.c:149:24
        #1 0x62f9e58c9dd2 in rb_gc_obj_free gc.c:1262:9
        #2 0x62f9e58f6e19 in gc_sweep_plane gc/default/default.c:3450:21
        #3 0x62f9e58f686a in gc_sweep_page gc/default/default.c:3535:13
        #4 0x62f9e58f12b4 in gc_sweep_step gc/default/default.c:3810:9
        #5 0x62f9e58ed2a7 in gc_sweep gc/default/default.c:4058:13
        #6 0x62f9e58fac93 in gc_start gc/default/default.c:6402:13
        #7 0x62f9e58e8b69 in heap_prepare gc/default/default.c:2032:13
        #8 0x62f9e58e8b69 in heap_next_free_page gc/default/default.c:2255:9
        #9 0x62f9e58e8b69 in newobj_cache_miss gc/default/default.c:2362:38
    ...
    0x5030000974f0 is located 16 bytes inside of 24-byte region [0x5030000974e0,0x5030000974f8)
    freed by thread T4 here:
        #0 0x62f9e562f28a in free (miniruby+0x1fd28a) (BuildId: 5ad6d9e7cec8318df6726ea5ce34d3c76d0d0233)
        #1 0x62f9e58ca2ab in rb_gc_impl_free gc/default/default.c:8102:9
        #2 0x62f9e58ca2ab in ruby_sized_xfree gc.c:5029:13
        #3 0x62f9e58ca2ab in ruby_xfree gc.c:5040:5
        #4 0x62f9e56f88e6 in rb_class_remove_from_super_subclasses class.c:152:9
        #5 0x62f9e58c9dd2 in rb_gc_obj_free gc.c:1262:9
        #6 0x62f9e58f6e19 in gc_sweep_plane gc/default/default.c:3450:21
        #7 0x62f9e58f686a in gc_sweep_page gc/default/default.c:3535:13
        #8 0x62f9e58f12b4 in gc_sweep_step gc/default/default.c:3810:9
        #9 0x62f9e58ed2a7 in gc_sweep gc/default/default.c:4058:13
    ...
    previously allocated by thread T5 here:
        #0 0x62f9e562f70d in calloc (miniruby+0x1fd70d) (BuildId: 5ad6d9e7cec8318df6726ea5ce34d3c76d0d0233)
        #1 0x62f9e58c8e1a in calloc1 gc/default/default.c:1472:12
        #2 0x62f9e58c8e1a in rb_gc_impl_calloc gc/default/default.c:8138:5
        #3 0x62f9e58c8e1a in ruby_xcalloc_body gc.c:4964:12
        #4 0x62f9e58c8e1a in ruby_xcalloc gc.c:4958:34
        #5 0x62f9e56f906e in push_subclass_entry_to_list class.c:88:13
        #6 0x62f9e56f906e in rb_class_subclass_add class.c:111:38
        #7 0x62f9e56f906e in RCLASS_SET_SUPER internal/class.h:257:9
        #8 0x62f9e56fca7a in make_metaclass class.c:786:5
        #9 0x62f9e59db982 in rb_class_initialize object.c:2101:5
2025-05-09 10:24:38 -04:00
Nobuyoshi Nakada
5349c0aa8c
Align gems/bundled_gems [ci skip] 2025-05-09 22:14:23 +09:00
Jean Boussier
15e3675ecc Remove dead code in rb_gc_impl_ractor_cache_free
Followup: https://github.com/ruby/ruby/pull/13286
2025-05-09 11:13:52 +02:00
Jean Boussier
ea77250847 Rename RB_OBJ_SHAPE -> rb_obj_shape
As well as `RB_OBJ_SHAPE_ID` -> `rb_obj_shape_id`
and `RSHAPE` is now a simple alias for `rb_shape_lookup`.

I tried to turn all these into `static inline` but I'm having
trouble with `RUBY_EXTERN rb_shape_tree_t *rb_shape_tree_ptr;`
not being exposed as I'd expect.
2025-05-09 10:22:51 +02:00
Jean Boussier
0b81359b3f Stop exposing rb_shape_frozen_shape_p 2025-05-09 10:22:51 +02:00
Jean Boussier
becc45ff4e Eliminate some rb_shape_t * usages outside of shape.c. 2025-05-09 10:22:51 +02:00
Jean Boussier
a970d35de2 Get rid of rb_shape_get_parent. 2025-05-09 10:22:51 +02:00
Jean Boussier
5782561fc1 Rename rb_shape_get_shape_id -> RB_OBJ_SHAPE_ID
And `rb_shape_get_shape` -> `RB_OBJ_SHAPE`.
2025-05-09 10:22:51 +02:00
Jean Boussier
a007575497 Remove unused rb_shape_object_id_index 2025-05-09 10:22:51 +02:00
Jean Boussier
c9b08882b7 Refactor rb_shape_get_next to return an ID
Also rename it, and change parameters to be consistent with
other transition functions.
2025-05-09 10:22:51 +02:00
Jean Boussier
e0200cfba0 Refactor rb_shape_transition_shape_remove_ivar to not take a shape pointer
It's more consistent with other transition functions.
2025-05-09 10:22:51 +02:00
Jean Boussier
3f7c0af051 Rename rb_shape_obj_too_complex -> rb_shape_obj_too_complex_p 2025-05-09 10:22:51 +02:00
Jean Boussier
677d075c29 Refactor rb_shape_transition_too_complex to return an ID. 2025-05-09 10:22:51 +02:00
Jean Boussier
f82523f14b Refactor rb_shape_transition_frozen to return a shape_id. 2025-05-09 10:22:51 +02:00
Jean Boussier
31d0a5815c Get rid of useless SHAPE_MASK 2025-05-09 10:22:51 +02:00
Jean Boussier
334ebba221 Rename rb_shape_get_shape_by_id -> RSHAPE 2025-05-09 10:22:51 +02:00
Jean Boussier
9966de11fb Refactor rb_shape_get_next_iv_shape to take and return ids. 2025-05-09 10:22:51 +02:00
Jean Boussier
df7d25bb3e Stop exposing rb_shape_get_root_shape 2025-05-09 10:22:51 +02:00
Jean Boussier
62eb2007f6 Remove unused rb_obj_debug_shape 2025-05-09 10:22:51 +02:00
Jean Boussier
e4f97ce387 Refactor rb_shape_depth to take an ID rather than a pointer.
As well as `rb_shape_edges_count` and `rb_shape_memsize`.
2025-05-09 10:22:51 +02:00