Skip to content

Ractor.make_shareable(proc_obj) makes inner structure shareable #7182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

luke-gru
Copy link
Contributor

@luke-gru luke-gru commented Jan 25, 2023

Proc objects are now traversed like other objects when making them shareable.

Fixes [Bug #19372]

https://bugs.ruby-lang.org/issues/19372

@luke-gru luke-gru force-pushed the make_shareable_proc_full_freeze branch from 368f1cf to 9c72957 Compare January 25, 2023 13:00
Proc objects are now traversed like other objects when making them
shareable.

Fixes [Bug #19372]
Fixes [Bug #19374]
@luke-gru luke-gru force-pushed the make_shareable_proc_full_freeze branch from 9c72957 to 41e6cdd Compare January 25, 2023 13:38
@@ -1284,6 +1284,7 @@ rb_proc_ractor_make_shareable(VALUE self)
}

FL_SET_RAW(self, RUBY_FL_SHAREABLE);
Copy link
Member

@jhawthorn jhawthorn Mar 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think because we're eagerly setting the flag here, this branch has the same issue as before (but it just needs two attempts 😅)

y = nil.instance_eval do
  foo = []
  proc { foo }.curry
end

begin
  Ractor.make_shareable(y)
rescue => e
  p exception: e
end
# => {exception: #<Ractor::IsolationError: can not make shareable Proc because it can refer unshareable object [] from variable 'foo'>}


p shareable: Ractor.make_shareable(y)
# => {shareable: #<Proc:0x00007cc25b895760>}
# No error!

p y.call.frozen? # => false

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I rebased and removed this flag set in 53b93d4 and I think that still does what's intended

@jhawthorn
Copy link
Member

This was merged in #12977 🎉

@jhawthorn jhawthorn closed this Mar 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants