[ruby-core:124156] [Ruby Bug#21775] Procs of type ifunc can access unshareable values
Issue #21775 has been reported by etienne (Étienne Barrié). ---------------------------------------- Bug #21775: Procs of type ifunc can access unshareable values https://bugs.ruby-lang.org/issues/21775 * Author: etienne (Étienne Barrié) * Status: Open * ruby -v: ruby 4.0.0preview2 (2025-11-17 master 4fa6e9938c) +PRISM [aarch64-linux] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- With this code, we can see that the Ractor is able to access the top-level main object. ``` ruby Ractor.alias_method :value, :take unless Ractor.method_defined?(:value) shareable_proc = Ractor.make_shareable(Hash.new { self }.to_proc) p shareable_proc[0] # => main p Ractor.new(shareable_proc) { |shareable_proc| shareable_proc[0] }.value # => main ``` The proc should not be shareable because its `self` is `main` which is not shareable. It impacts all the versions since Ractors were introduced. `Ractor.shareable_proc` should be able to replace `self` with `nil`. -- https://bugs.ruby-lang.org/
participants (1)
-
etienne