Skip to content
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

Fix Ractor.make_shareable changing locals for Procs #4940

Merged
merged 1 commit into from
Oct 6, 2021

Conversation

XrXr
Copy link
Member

@XrXr XrXr commented Oct 6, 2021

env_copy() uses rb_ary_delete_at() with a loop counting up while
iterating through the list of read only locals. rb_ary_delete_at() can
shift elements in the array to an index lesser than the loop index,
causing locals to be missed and being set to Qfalse in the returned
environment.

Iterate through the list of locals in reverse instead, this way we
always remove the last element and not cause elements in the array to
shift. This ensures that all read only locals are handled.

[Bug #18023]

env_copy() uses rb_ary_delete_at() with a loop counting up while
iterating through the list of read only locals. rb_ary_delete_at() can
shift elements in the array to an index lesser than the loop index,
causing locals to be missed and being set to Qfalse in the returned
environment.

Iterate through the list of locals in reverse instead, this way we
always remove the last element and not cause elements in the array to
shift. This ensures that all read only locals are handled.

[Bug #18023]
@XrXr XrXr requested a review from ko1 October 6, 2021 16:43
Copy link
Contributor

@ko1 ko1 left a comment

Choose a reason for hiding this comment

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

💯

@XrXr XrXr merged commit 7622819 into ruby:master Oct 6, 2021
@XrXr XrXr deleted the make-shareable-proc-locals branch October 6, 2021 19:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants