Skip to content

[Truffle] Incorrect frame used for block variable access #3001

Closed
@nirvdrum

Description

@nirvdrum

This is a complicated example that's been distilled down from a larger problem JRuby+Truffle has running RSpec. What appears to be happening is a variable declared in some ancestor frame is being accessed from the current frame instead. In this case, the frame slot index exceeds the number of locals in the frame and an exception is thrown.

Example:

class X
  def y(new_name)
    yield(:y_name)
  end

  def z(name, opts)
    yield
  end

  def w(category, name, backtrace_line, *args)
    p backtrace_line
  end

  def x(new_name, label = 'default')
    y(new_name) do |name, *args, &block|
      group = z(name, :caller => (the_caller = caller)) do
        w("examples", name, the_caller.first, *args, &block)
      end
    end
  end
end

X.new.x(:x_name)

MRI 2.2.2:

> ruby -v blah.rb 
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
blah.rb:16: warning: assigned but unused variable - group
"blah.rb:3:in `y'

JRuby+Truffle:

> bin/jruby -X+T -v blah.rb 
jruby 9.0.0.0-SNAPSHOT (2.2.2) 2015-05-28 e0b1489 Java HotSpot(TM) 64-Bit Server VM 25.45-b02 on 1.8.0_45-b14 +jit [linux-amd64]
blah.rb:6:in `z': internal implementation error - IllegalArgumentException The frame slot '[4,the_caller,Object]' is not known by the frame descriptor. com.oracle.truffle.api.impl.DefaultVirtualFrame.getSlotIndexChecked(DefaultVirtualFrame.java:161) (RubyTruffleError)
    from blah.rb:16:in `block in x'
    from blah.rb:3:in `y'
    from blah.rb:15:in `x'
    from blah.rb:23:in `<main>'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions