-
Notifications
You must be signed in to change notification settings - Fork 5.4k
(rebase) Ractor.make_shareable(proc_obj) makes inner structure shareable #12977
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
(rebase) Ractor.make_shareable(proc_obj) makes inner structure shareable #12977
Conversation
Proc objects are now traversed like other objects when making them shareable. Fixes [Bug #19372] Fixes [Bug #19374]
✅ All Tests passed!✖️no tests failed ✔️61702 tests passed(1 flake) |
@@ -1415,7 +1415,7 @@ rb_proc_ractor_make_shareable(VALUE self) | |||
proc->is_isolated = TRUE; | |||
} | |||
|
|||
FL_SET_RAW(self, RUBY_FL_SHAREABLE); | |||
rb_obj_freeze(self); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it mark shareable flag on a Proc later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does after traversing through the objects as part of rb_ractor_make_shareable
. Setting it here before was allowing unfrozen objects to leak through.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ok, mark_shareable
will set.
Strictly speaking the Proc is not needed to be frozen, but okay.
no problem to merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to freeze to prevent instance variables from being set after it's made shareable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it is safer. But for example Ractor objects are shareable but not frozen. The instance variables can be accessed only from main ractor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! I see, thank you. I didn't see that behaviour in generic_ivtbl
This is a rebase of #7182 with one tiny fix (not setting RUBY_FL_SHAREABLE) and I've added some additional tests
This PR adjusts
Ractor.make_shareable
to be more strict, and ensure all reachable objects from it are shareable (including ivars, Methods, etc)