@@ -2444,35 +2444,45 @@ def call_test(obj)
24442444# When creating bmethods in Ractors, they should only be usable from their
24452445# defining ractor, even if it is GC'd
24462446assert_equal 'ok' , <<~'RUBY'
2447- CLASSES = 1000.times.map { Class.new }.freeze
24482447
2449- # This would be better to run in parallel, but there's a bug with lambda
2450- # creation and YJIT causing crashes in dev mode
2451- ractors = CLASSES.map do |klass|
2452- Ractor.new(klass) do |klass|
2453- Ractor.receive
2454- klass.define_method(:foo) {}
2448+ begin
2449+ CLASSES = 1000.times.map { Class.new }.freeze
2450+
2451+ # This would be better to run in parallel, but there's a bug with lambda
2452+ # creation and YJIT causing crashes in dev mode
2453+ ractors = CLASSES.map do |klass|
2454+ Ractor.new(klass) do |klass|
2455+ Ractor.receive
2456+ klass.define_method(:foo) {}
2457+ end
24552458 end
2456- end
24572459
2458- ractors.each do |ractor|
2459- ractor << nil
2460- ractor.join
2461- end
2460+ ractors.each do |ractor|
2461+ ractor << nil
2462+ ractor.join
2463+ end
24622464
2463- ractors.clear
2464- GC.start
2465+ ractors.clear
2466+ GC.start
24652467
2466- any = 1000.times.map do
2467- Ractor.new do
2468- CLASSES.any? do |klass|
2469- begin
2470- klass.new.foo
2471- true
2472- rescue RuntimeError
2473- false
2468+ any = 1000.times.map do
2469+ Ractor.new do
2470+ CLASSES.any? do |klass|
2471+ begin
2472+ klass.new.foo
2473+ true
2474+ rescue RuntimeError
2475+ false
2476+ end
24742477 end
24752478 end
2479+ end.map(&:value).none? && :ok
2480+ rescue ThreadError => e
2481+ # ignore limited memory machine
2482+ if /can\'t create Thread/ =~ e.message
2483+ :ok
2484+ else
2485+ raise
24762486 end
2477- end.map(&:value).none? && :ok
2487+ end
24782488RUBY
0 commit comments