From: "jhawthorn (John Hawthorn) via ruby-core" Date: 2025-07-03T00:39:53+00:00 Subject: [ruby-core:122647] [Ruby Bug#17359] Ractor copy mode is not Ractor-safe Issue #17359 has been updated by jhawthorn (John Hawthorn). Seems to still be an issue. Here's an updated reproduction for 3.5dev (Using Ractor::Port instead of take/yield) ``` ruby class Foo attr_accessor :x def initialize_copy(*) $last = self super end end o = Foo.new o.x = 42 port = Ractor::Port.new r = Ractor.new(o, port) do |copy, port| puts copy.x # => 42 port << :sync Ractor.receive puts copy.x # => 666 end port.receive # => :sync $last.x = 666 r.send :continue r.join ``` ---------------------------------------- Bug #17359: Ractor copy mode is not Ractor-safe https://bugs.ruby-lang.org/issues/17359#change-113923 * Author: marcandre (Marc-Andre Lafortune) * Status: Assigned * Assignee: ractor * ruby -v: ruby 3.0.0dev (2020-11-30T10:06:25Z master 89774a938a) [x86_64-darwin18] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- It should not be possible to mutate an object across Ractors, but the copy mode allows it currently: ```ruby class Foo attr_accessor :x def initialize_copy(*) $last = self super end end o = Foo.new o.x = 42 r = Ractor.new(o) do |copy| puts copy.x # => 42 Ractor.yield :sync Ractor.yield :sync puts copy.x # => 666 end r.take # => :sync $last.x = 666 r.take # => :sync r.take ``` Maybe the `copy` object should be marked as moved? -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/