91898 Commits

Author SHA1 Message Date
OrenGitHub
e2f5e233b5 [ruby/psych] exception tests
https://github.com/ruby/psych/commit/1e9b79f699
2025-05-09 17:53:18 +00:00
OrenGitHub
42328d4ef4 [ruby/psych] more special cases
https://github.com/ruby/psych/commit/b33bf8b060
2025-05-09 17:53:18 +00:00
OrenGitHub
451e1dcf31 [ruby/psych] duplicate more tests
https://github.com/ruby/psych/commit/a3be6429bf
2025-05-09 17:53:17 +00:00
OrenGitHub
ae299cc9cd [ruby/psych] add first test for safe load stream
https://github.com/ruby/psych/commit/336553b412
2025-05-09 17:53:17 +00:00
OrenGitHub
f0e2a41d4b [ruby/psych] fixed bugs from testing
https://github.com/ruby/psych/commit/e954f96639
2025-05-09 17:53:17 +00:00
OrenGitHub
d69319304f [ruby/psych] Add safe version for load_stream
https://github.com/ruby/psych/commit/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
Jean Boussier
f8b3fc520f Refactor rb_shape_traverse_from_new_root to not expose rb_shape_t 2025-05-09 10:22:51 +02:00
Jean Boussier
7116b0a7f1 Extract rb_shape_free_all 2025-05-09 10:22:51 +02:00
John Hawthorn
30ef0f180b Fix allocation count when forking with Ractors
After fork we reset to single ractor mode (which IMO we shouldn't do,
but it requires more work to fix) and so we need to add the pending
object counts back to the main heap.
2025-05-09 00:55:14 -07:00
Jean Boussier
4de049a3f9 Deprecate ObjectSpace._id2ref
[Feature #15408]

Matz decided to deprecate it for Ruby 2.6 or 2.7 but that never
actually happened.

Given the object_id table is a contention point for Ractors
it seems sensible to finally deprecate this API so we can
generate and store object ids more efficiently in the future.
2025-05-09 09:19:25 +02:00
Hiroshi SHIBATA
4ef324c7c1
Added https://bugs.ruby-lang.org/issues/21258 to NEWS.md 2025-05-09 15:37:01 +09:00
git
dcd0a35c6d Update default gems list at d3c472781dec4fe415203fbb898d8b [ci skip] 2025-05-09 05:28:22 +00:00
Hiroshi SHIBATA
d3c472781d Replaced CGI.parse with URI.decode_www_form 2025-05-09 14:27:28 +09:00
Hiroshi SHIBATA
ab19b1f629 Use CGI 0.5.0.beta1 2025-05-09 14:27:28 +09:00
Hiroshi SHIBATA
5e1c90675e Added cgi for bundler testing. rack depends cgi/cookie.rb 2025-05-09 14:27:28 +09:00
Hiroshi SHIBATA
5aade8a84a Added migration wrapper for cgi.rb and cgi/util.rb 2025-05-09 14:27:28 +09:00
Hiroshi SHIBATA
ce6c1778fb Guard CGI examples with Ruby 3.5 and use cgi/escape for related examples 2025-05-09 14:27:28 +09:00
Hiroshi SHIBATA
600c616507 Removed CGI library without CGI::Escape features 2025-05-09 14:27:28 +09:00
Hiroshi SHIBATA
a61f51f66d Use cgi/escape instead of cgi/util 2025-05-09 14:27:28 +09:00
Hiroshi SHIBATA
56423d43a3 Reduce loading class/module on CGIUtilTest and CGIEscapeTest 2025-05-09 14:27:28 +09:00
Hiroshi SHIBATA
382be44f42 Extract CGIEscapeTest from CGIUtilTest 2025-05-09 14:27:28 +09:00
Hiroshi SHIBATA
8a1d45144b Support require 'cgi/escape' with extracting CGI::Escape from CGI::Util 2025-05-09 14:27:28 +09:00
Hiroshi SHIBATA
c667683768
Added instruction for initial setup of depend file 2025-05-09 13:51:44 +09:00
BurdetteLamar
7a660d7c69 [DOC] Tweaks for What's Here 2025-05-08 16:34:33 -04:00
Jean Boussier
b67711b17a Fix remove_instance_variable on complex objects
Introduced in: https://github.com/ruby/ruby/pull/13159

Now that there is no longer a unique TOO_COMPLEX shape with
no children, checking `shape->type == TOO_COMPLEX` is incorrect.
2025-05-08 21:48:35 +02:00
Aaron Patterson
e3452cfad2 Raise error on take/send for Ractors in child processes
Ractor objects that are available in a child process should raise a
`Ractor::ClosedError` exception when called with `send` or `take`

Co-authored-by: John Hawthorn <john@hawthorn.email>
2025-05-08 10:53:28 -07:00
Aaron Patterson
f7ff380998 Clean up Ractor cache after fork
Ractors created in a parent process should be properly shut down in the
child process.  They need their cache cleared and status set to
"terminated"

Co-authored-by: John Hawthorn <john@hawthorn.email>
2025-05-08 10:53:28 -07:00
John Hawthorn
d7ad53f249 Acquire VM lock around fork
Otherwise it might be held by another Ractor, causing a deadlock in the
new process.
2025-05-08 10:53:28 -07:00