Skip to content

ZJIT: Local variable clobbered on --zjit-disable-hir-opt #970

@XrXr

Description

@XrXr

The following test (reduced from ruby-spec) fails:

# ./miniruby --zjit-call-threshold=1 --zjit-disable-hir-opt test.rb
def test
  ofor = nil
  n = 0
  eval("n = 2")
  raise unless ofor.nil? # commenting out this line dodges the bug
  raise "n=#{n} and !=2" unless n == 2
end
test
test

The ofor.nil? call causes a local variable spill, clobbering the n assigned in eval.

Some ways to fix this:

  • Reload all local variables after each Send, like we already do for Send with a block.
  • Put a PatchPoint NoEpEscape after each send
  • Reason about what value each local variable could hold in an optimization pass instead of during HIR build, loading/storing through EP like the interpreter as a baseline (Though, this might fix the symptom but not the root cause.)

We want to have a discussion before picking an option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions