Skip to content

ZJIT: YJIT: [Bug #22546] Fix Bug with large memory displacement lowering from too many Ruby local variables - #20238

Open
XrXr wants to merge 2 commits into
ruby:masterfrom
XrXr:zjit-fix-mem-displacement
Open

XrXr wants to merge 2 commits into
ruby:masterfrom
XrXr:zjit-fix-mem-displacement

Conversation

@XrXr

@XrXr XrXr commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

See each commit. This is mostly a YJIT PR with ZJIT mostly tagging along for the ride since we don't have a ruby level repro for ZJIT. I'm just porting encoder fix over to ZJIT. Ref #20213

ZJIT has test_emit_lea which covers what the added test_lea_with_large_displacement tests.

@matzbot
matzbot requested a review from a team November 27, 2026 03:04
@github-actions github-actions Bot added the jit YJIT, ZJIT, ... label Nov 27, 2026
@github-actions

Copy link
Copy Markdown

This pull request references the following Redmine tickets:

@XrXr
XrXr marked this pull request as draft November 27, 2026 03:07
@XrXr XrXr changed the title ZJIT: x64: Fix truncation of memory displacement larger than 16 bit ZJIT: YJIT: [Bug #22546] Nov 27, 2026
@XrXr
XrXr force-pushed the zjit-fix-mem-displacement branch from c14f454 to aa99135 Compare November 27, 2026 03:36
@XrXr XrXr changed the title ZJIT: YJIT: [Bug #22546] ZJIT: YJIT: [Bug #22546] Fix Bug with large memory displacement lowering from too many Ruby local variables Nov 27, 2026
This is the same fix as 8b7fab6,
applied to ZJIT. That commit, the parent commit, and this commit combine
to fix [Bug #22546] as far as I can tell. Previously, there was silent
truncation of 32-bit displacements outside `[-32768, 32767]`.

I don't know of a way to trigger this issue from ruby code with ZJIT, as
there are other (unrelated) checks that obscure creating a problematic
memory operand. ZJIT gets some testing of many-locals situation through
the new test in bootstraptest/test_yjit.rb.
@XrXr
XrXr force-pushed the zjit-fix-mem-displacement branch from aa99135 to e6ee41f Compare November 27, 2026 03:51
@XrXr
XrXr marked this pull request as ready for review November 27, 2026 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jit YJIT, ZJIT, ...

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant