Issue #21649 has been reported by jhawthorn (John Hawthorn). ---------------------------------------- Bug #21649: Ractors can access non-shareable object through singleton classes https://bugs.ruby-lang.org/issues/21649 * Author: jhawthorn (John Hawthorn) * Status: Open * Assignee: ractor * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- If we send a non-shareable object into a Ractor, it needs to be copied. ``` ❯ ruby -W0 -e 'Ractor.new(p(Object.new)) { |o| p(o) }.join' #<Object:0x00000001240f8cf8> #<Object:0x00000001240f8870> ``` However we're able to instead smuggle it through a singleton class to unsafely get a mutable reference to the same object in both Ractors. ``` ❯ ruby -W0 -e 'Ractor.new(p(Object.new).singleton_class) { |o| p(o.attached_object) }.join' #<Object:0x0000000120768c40> #<Object:0x0000000120768c40> ``` I think we should probably make singleton classes copy the shareability of their attached object. -- https://bugs.ruby-lang.org/