Skip to content

Commit f9c8c05

Browse files
committed
Merge branch 'Ractor-Local-GC-version-3' into Ractor-Local-GC-version-1.1
2 parents 090c591 + d009adf commit f9c8c05

File tree

407 files changed

+7402
-4735
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

407 files changed

+7402
-4735
lines changed

.gdbinit

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,8 +1296,7 @@ end
12961296

12971297
define print_flags
12981298
printf "RUBY_FL_WB_PROTECTED: %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_WB_PROTECTED ? "1" : "0"
1299-
printf "RUBY_FL_PROMOTED0 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_PROMOTED0 ? "1" : "0"
1300-
printf "RUBY_FL_PROMOTED1 : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_PROMOTED1 ? "1" : "0"
1299+
printf "RUBY_FL_PROMOTED : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_PROMOTED ? "1" : "0"
13011300
printf "RUBY_FL_FINALIZE : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_FINALIZE ? "1" : "0"
13021301
printf "RUBY_FL_SHAREABLE : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_SHAREABLE ? "1" : "0"
13031302
printf "RUBY_FL_EXIVAR : %s\n", ((struct RBasic*)($arg0))->flags & RUBY_FL_EXIVAR ? "1" : "0"

.github/workflows/dependabot_automerge.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
# from https://github.com/gofiber/swagger/blob/main/.github/workflows/dependabot_automerge.yml
22
name: Dependabot auto-merge
33
on:
4-
pull_request_target:
4+
pull_request:
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
59

610
jobs:
711
automerge:
812
runs-on: ubuntu-latest
9-
10-
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
11-
13+
if: github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'ruby/ruby'
1214
steps:
1315
- name: Dependabot metadata
1416
uses: dependabot/fetch-metadata@dbb049abf0d677abbd7f7eee0375145b417fdd34 # v2.2.0

.github/workflows/spec_guards.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ jobs:
4141
# Specs from ruby/spec should still run on all supported Ruby versions.
4242
# This also ensures the needed ruby_version_is guards are there, see spec/README.md.
4343
ruby:
44-
- ruby-3.0
4544
- ruby-3.1
4645
- ruby-3.2
4746
- ruby-3.3

.github/workflows/windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ jobs:
105105
run: |
106106
iex "& {$(irm get.scoop.sh)} -RunAsAdmin"
107107
Join-Path (Resolve-Path ~).Path "scoop\shims" >> $Env:GITHUB_PATH
108-
scoop install vcpkg
108+
scoop install vcpkg cmake@3.31.6
109109
shell: pwsh
110110

111111
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0

LEGAL

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,44 @@ mentioned below.
702702
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
703703
SUCH DAMAGE.
704704

705+
[ext/json/vendor/fpconv.c]
706+
707+
This file is under the Boost Software License.
708+
709+
>>>
710+
Boost Software License - Version 1.0 - August 17th, 2003
711+
712+
Permission is hereby granted, free of charge, to any person or organization
713+
obtaining a copy of the software and accompanying documentation covered by
714+
this license (the "Software") to use, reproduce, display, distribute,
715+
execute, and transmit the Software, and to prepare derivative works of the
716+
Software, and to permit third-parties to whom the Software is furnished to
717+
do so, all subject to the following:
718+
719+
The copyright notices in the Software and this entire statement, including
720+
the above license grant, this restriction and the following disclaimer,
721+
must be included in all copies of the Software, in whole or in part, and
722+
all derivative works of the Software, unless such copies or derivative
723+
works are solely in the form of machine-executable object code generated by
724+
a source language processor.
725+
726+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
727+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
728+
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
729+
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
730+
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
731+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
732+
DEALINGS IN THE SOFTWARE.
733+
734+
[ext/json/vendor/jeaiii-ltoa.h]
735+
736+
>>>
737+
Copyright (c) 2024,2025 Enrico Thierbach - https://github.com/radiospiel
738+
Copyright (c) 2022 James Edward Anhalt III - https://github.com/jeaiii/itoa
739+
740+
{MIT License}[rdoc-ref:@MIT+License]
741+
742+
705743
[ext/psych]
706744
[test/psych]
707745

NEWS.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ Note that each entry is kept to a minimum, see links for details.
77

88
## Language changes
99

10+
* `*nil` no longer calls `nil.to_a`, similar to how `**nil` does
11+
not call `nil.to_hash`. [[Feature #21047]]
12+
1013
## Core classes updates
1114

1215
Note: We're only listing outstanding class updates.
@@ -29,11 +32,11 @@ The following bundled gems are promoted from default gems.
2932
* ostruct 0.6.1
3033
* pstore 0.2.0
3134
* benchmark 0.4.0
32-
* logger 1.6.6
33-
* rdoc 6.12.0
35+
* logger 1.7.0
36+
* rdoc 6.13.1
3437
* win32ole 1.9.1
35-
* irb 1.15.1
36-
* reline 0.6.0
38+
* irb 1.15.2
39+
* reline 0.6.1
3740
* readline 0.0.4
3841
* fiddle 1.1.6
3942

@@ -54,7 +57,7 @@ The following default gems are updated.
5457
* optparse 0.7.0.dev.2
5558
* prism 1.4.0
5659
* psych 5.2.3
57-
* stringio 3.1.6.dev
60+
* stringio 3.1.6
5861
* uri 1.0.3
5962

6063
The following bundled gems are added.
@@ -63,13 +66,15 @@ The following bundled gems are added.
6366
The following bundled gems are updated.
6467

6568
* minitest 5.25.5
69+
* test-unit 3.6.8
6670
* rexml 3.4.1
6771
* net-imap 0.5.6
6872
* net-smtp 0.5.1
69-
* rbs 3.8.1
73+
* rbs 3.9.2
7074
* bigdecimal 3.1.9
7175
* syslog 0.3.0
72-
* repl_type_completor 0.1.10
76+
* csv 3.3.3
77+
* repl_type_completor 0.1.11
7378

7479
## Supported platforms
7580

@@ -84,4 +89,5 @@ The following bundled gems are updated.
8489
## JIT
8590

8691
[Feature #19908]: https://bugs.ruby-lang.org/issues/19908
92+
[Feature #21047]: https://bugs.ruby-lang.org/issues/21047
8793
[Bug #21049]: https://bugs.ruby-lang.org/issues/21049

benchmark/nilclass.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
prelude: |
2+
def a = nil
13
benchmark:
24
to_i: |
35
nil.to_i
46
to_f: |
57
nil.to_f
8+
splat: |
9+
a(*nil)
610
loop_count: 100000

bootstraptest/test_literal.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@
117117
assert_equal 'true', 'a = [obj = Object.new]; a[0] == obj'
118118
assert_equal '5', 'a = [1,2,3]; a[1] = 5; a[1]'
119119
assert_equal 'bar', '[*:foo];:bar'
120-
assert_equal '[1, 2]', 'def nil.to_a; [2]; end; [1, *nil]'
121-
assert_equal '[1, 2]', 'def nil.to_a; [1, 2]; end; [*nil]'
120+
assert_equal '[]', 'def nil.to_a; [1, 2]; end; [*nil]'
121+
assert_equal '[1]', 'def nil.to_a; [2]; end; [1, *nil]'
122122
assert_equal '[0, 1, {2 => 3}]', '[0, *[1], 2=>3]', "[ruby-dev:31592]"
123123

124124

bootstraptest/test_method.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,3 +1419,11 @@ def internal_foo = foo
14191419
"ok"
14201420
end
14211421
}
1422+
1423+
assert_equal 'ok', <<~RUBY
1424+
def test(*, kw: false)
1425+
"ok"
1426+
end
1427+
1428+
test
1429+
RUBY

bootstraptest/test_ractor.rb

Lines changed: 173 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,28 @@ def /(other)
13611361
Ractor.shareable?(pr)
13621362
}
13631363

1364+
# Ractor.make_shareable(a_proc) makes inner structure shareable and freezes it
1365+
assert_equal 'true,true,true,true', %q{
1366+
class Proc
1367+
attr_reader :obj
1368+
def initialize
1369+
@obj = Object.new
1370+
end
1371+
end
1372+
1373+
pr = Ractor.current.instance_eval do
1374+
Proc.new {}
1375+
end
1376+
1377+
results = []
1378+
Ractor.make_shareable(pr)
1379+
results << Ractor.shareable?(pr)
1380+
results << pr.frozen?
1381+
results << Ractor.shareable?(pr.obj)
1382+
results << pr.obj.frozen?
1383+
results.map(&:to_s).join(',')
1384+
}
1385+
13641386
# Ractor.shareable?(recursive_objects)
13651387
assert_equal '[false, false]', %q{
13661388
y = []
@@ -1389,6 +1411,21 @@ module M; end
13891411
Ractor.make_shareable(ary = [C, M])
13901412
}
13911413

1414+
# Ractor.make_shareable with curried proc checks isolation of original proc
1415+
assert_equal 'isolation error', %q{
1416+
a = Object.new
1417+
orig = proc { a }
1418+
curried = orig.curry
1419+
1420+
begin
1421+
Ractor.make_shareable(curried)
1422+
rescue Ractor::IsolationError
1423+
'isolation error'
1424+
else
1425+
'no error'
1426+
end
1427+
}
1428+
13921429
# define_method() can invoke different Ractor's proc if the proc is shareable.
13931430
assert_equal '1', %q{
13941431
class C
@@ -1599,7 +1636,7 @@ class C
15991636
16001637
1_000.times { idle_worker, tmp_reporter = Ractor.select(*workers) }
16011638
"ok"
1602-
} unless yjit_enabled? # flaky
1639+
} if !yjit_enabled? && ENV['GITHUB_WORKFLOW'] != 'ModGC' # flaky
16031640

16041641
assert_equal "ok", %q{
16051642
def foo(*); ->{ super }; end
@@ -1950,3 +1987,138 @@ def require feature
19501987
GC.start
19511988
:ok.itself
19521989
}
1990+
1991+
# moved objects being corrupted if embeded (String)
1992+
assert_equal 'ok', %q{
1993+
ractor = Ractor.new { Ractor.receive }
1994+
obj = "foobarbazfoobarbazfoobarbazfoobarbaz"
1995+
ractor.send(obj.dup, move: true)
1996+
roundtripped_obj = ractor.take
1997+
roundtripped_obj == obj ? :ok : roundtripped_obj
1998+
}
1999+
2000+
# moved objects being corrupted if embeded (Array)
2001+
assert_equal 'ok', %q{
2002+
ractor = Ractor.new { Ractor.receive }
2003+
obj = Array.new(10, 42)
2004+
ractor.send(obj.dup, move: true)
2005+
roundtripped_obj = ractor.take
2006+
roundtripped_obj == obj ? :ok : roundtripped_obj
2007+
}
2008+
2009+
# moved objects being corrupted if embeded (Hash)
2010+
assert_equal 'ok', %q{
2011+
ractor = Ractor.new { Ractor.receive }
2012+
obj = { foo: 1, bar: 2 }
2013+
ractor.send(obj.dup, move: true)
2014+
roundtripped_obj = ractor.take
2015+
roundtripped_obj == obj ? :ok : roundtripped_obj
2016+
}
2017+
2018+
# moved objects being corrupted if embeded (MatchData)
2019+
assert_equal 'ok', %q{
2020+
ractor = Ractor.new { Ractor.receive }
2021+
obj = "foo".match(/o/)
2022+
ractor.send(obj.dup, move: true)
2023+
roundtripped_obj = ractor.take
2024+
roundtripped_obj == obj ? :ok : roundtripped_obj
2025+
}
2026+
2027+
# moved objects being corrupted if embeded (Struct)
2028+
assert_equal 'ok', %q{
2029+
ractor = Ractor.new { Ractor.receive }
2030+
obj = Struct.new(:a, :b, :c, :d, :e, :f).new(1, 2, 3, 4, 5, 6)
2031+
ractor.send(obj.dup, move: true)
2032+
roundtripped_obj = ractor.take
2033+
roundtripped_obj == obj ? :ok : roundtripped_obj
2034+
}
2035+
2036+
# moved objects being corrupted if embeded (Object)
2037+
assert_equal 'ok', %q{
2038+
ractor = Ractor.new { Ractor.receive }
2039+
class SomeObject
2040+
attr_reader :a, :b, :c, :d, :e, :f
2041+
def initialize
2042+
@a = @b = @c = @d = @e = @f = 1
2043+
end
2044+
2045+
def ==(o)
2046+
@a == o.a &&
2047+
@b == o.b &&
2048+
@c == o.c &&
2049+
@d == o.d &&
2050+
@e == o.e &&
2051+
@f == o.f
2052+
end
2053+
end
2054+
2055+
SomeObject.new # initial non-embeded
2056+
2057+
obj = SomeObject.new
2058+
ractor.send(obj.dup, move: true)
2059+
roundtripped_obj = ractor.take
2060+
roundtripped_obj == obj ? :ok : roundtripped_obj
2061+
}
2062+
2063+
# moved arrays can't be used
2064+
assert_equal 'ok', %q{
2065+
ractor = Ractor.new { Ractor.receive }
2066+
obj = [1]
2067+
ractor.send(obj, move: true)
2068+
begin
2069+
[].concat(obj)
2070+
rescue TypeError
2071+
:ok
2072+
else
2073+
:fail
2074+
end
2075+
}
2076+
2077+
# moved strings can't be used
2078+
assert_equal 'ok', %q{
2079+
ractor = Ractor.new { Ractor.receive }
2080+
obj = "hello"
2081+
ractor.send(obj, move: true)
2082+
begin
2083+
"".replace(obj)
2084+
rescue TypeError
2085+
:ok
2086+
else
2087+
:fail
2088+
end
2089+
}
2090+
2091+
# moved hashes can't be used
2092+
assert_equal 'ok', %q{
2093+
ractor = Ractor.new { Ractor.receive }
2094+
obj = { a: 1 }
2095+
ractor.send(obj, move: true)
2096+
begin
2097+
{}.merge(obj)
2098+
rescue TypeError
2099+
:ok
2100+
else
2101+
:fail
2102+
end
2103+
}
2104+
2105+
# move objects inside frozen containers
2106+
assert_equal 'ok', %q{
2107+
ractor = Ractor.new { Ractor.receive }
2108+
obj = Array.new(10, 42)
2109+
original = obj.dup
2110+
ractor.send([obj].freeze, move: true)
2111+
roundtripped_obj = ractor.take[0]
2112+
roundtripped_obj == original ? :ok : roundtripped_obj
2113+
}
2114+
2115+
# move object with generic ivar
2116+
assert_equal 'ok', %q{
2117+
ractor = Ractor.new { Ractor.receive }
2118+
obj = Array.new(10, 42)
2119+
obj.instance_variable_set(:@array, [1])
2120+
2121+
ractor.send(obj, move: true)
2122+
roundtripped_obj = ractor.take
2123+
roundtripped_obj.instance_variable_get(:@array) == [1] ? :ok : roundtripped_obj
2124+
}

0 commit comments

Comments
 (0)