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

YJIT: Fix gen_expandarray treating argument as VALUE #6603

Merged
merged 1 commit into from Oct 20, 2022

Conversation

XrXr
Copy link
Member

@XrXr XrXr commented Oct 20, 2022

The expandarray instruction interpreters its arguments as rb_num_t. YJIT was treating the num argument as a VALUE previously and when it has a certain bit pattern, it can look like a GC pointer. The argument is not a pointer, so YJIT crashed when trying to mark those pointers.

This bug existed previously, but our test suite didn't expose it until f55212b. TestArgf#test_to_io has a line like:

a1, a2, a3, a4, a5, a6, a7, a8 = array

Which maps to an expandarray with an argument of 8. Qnil happened to be defined as 8, which masked the issue.

Fix it by not using the argument as a VALUE.

The expandarray instruction interpreters its arguments as rb_num_t.
YJIT was treating the num argument as a VALUE previously and when
it has a certain bit pattern, it can look like a GC pointer. The
argument is not a pointer, so YJIT crashed when trying to mark those
pointers.

This bug existed previously, but our test suite didn't expose it until
f55212b. TestArgf#test_to_io has a
line like:

    a1, a2, a3, a4, a5, a6, a7, a8 = array

Which maps to an expandarray with an argument of 8. Qnil happened to
be defined as 8, which masked the issue.

Fix it by not using the argument as a VALUE.
@XrXr XrXr requested a review from k0kubun October 20, 2022 21:04
@matzbot matzbot requested a review from a team October 20, 2022 21:05
Copy link
Member

@k0kubun k0kubun left a comment

Choose a reason for hiding this comment

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

Thanks 🙏

@XrXr XrXr merged commit 39f7edd into ruby:master Oct 20, 2022
@XrXr XrXr deleted the yjit-expand-array branch October 20, 2022 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants