Project

General

Profile

Actions

Bug #21775

open

Procs of type ifunc can access unshareable values

Bug #21775: Procs of type ifunc can access unshareable values

Added by etienne (Étienne Barrié) about 5 hours ago.

Status:
Open
Assignee:
-
Target version:
-
ruby -v:
ruby 4.0.0preview2 (2025-11-17 master 4fa6e9938c) +PRISM [aarch64-linux]
[ruby-core:124156]

Description

With this code, we can see that the Ractor is able to access the top-level main object.

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.

No data to display

Actions

Also available in: PDF Atom