nil initialization missing from optionally-set argument #4251

Closed
headius opened this Issue Oct 26, 2016 · 1 comment

Projects

None yet

1 participant

@headius
Member
headius commented Oct 26, 2016

Environment

Current JRuby master (pre-9.1.6.0)

Expected Behavior

This script should work:

def foo(a=(b=1))
  [a,b]
end

foo

Actual Behavior

The jitted code fails to verify because the load of b happens before it has been initialized. It should have been set to nil somewhere before that.

This is currently causing CI of rake spec:compiler to fail.

$ jruby -Xjit.logging -Xjit.logging.verbose -e 'def foo(a=(b=1));[a,b];end;foo'
2016-10-26T18:01:42.934-05:00 [main] ERROR Ruby : failed to compile target script -e: 
org.jruby.compiler.NotCompilableException: failed to compile script -e
    at org.jruby.ir.Compiler.execute(Compiler.java:62)
    at org.jruby.ir.Compiler.execute(Compiler.java:31)
    at org.jruby.ir.IRTranslator.execute(IRTranslator.java:42)
    at org.jruby.Ruby.tryCompile(Ruby.java:823)
    at org.jruby.Ruby.precompileCLI(Ruby.java:788)
    at org.jruby.Ruby.runNormally(Ruby.java:750)
    at org.jruby.Ruby.runNormally(Ruby.java:779)
    at org.jruby.Ruby.runFromMain(Ruby.java:592)
    at org.jruby.Main.doRunFromMain(Main.java:425)
    at org.jruby.Main.internalRun(Main.java:313)
    at org.jruby.Main.run(Main.java:242)
    at org.jruby.Main.main(Main.java:204)
Caused by: java.lang.VerifyError: Bad local variable type
Exception Details:
  Location:
    DashE.RUBY$method$foo$0(Lorg/jruby/runtime/ThreadContext;Lorg/jruby/parser/StaticScope;Lorg/jruby/runtime/builtin/IRubyObject;[Lorg/jruby/runtime/builtin/IRubyObject;Lorg/jruby/runtime/Block;Lorg/jruby/RubyModule;Ljava/lang/String;)Lorg/jruby/runtime/builtin/IRubyObject; @59: aload
  Reason:
    Type top (current frame, locals[9]) is not assignable to reference type
  Current Frame:
    bci: @59
    flags: { }
    locals: { 'org/jruby/runtime/ThreadContext', 'org/jruby/parser/StaticScope', 'org/jruby/runtime/builtin/IRubyObject', '[Lorg/jruby/runtime/builtin/IRubyObject;', 'org/jruby/runtime/Block', 'org/jruby/RubyModule', 'java/lang/String', top, 'org/jruby/runtime/builtin/IRubyObject' }
    stack: { 'org/jruby/runtime/ThreadContext', 'org/jruby/runtime/builtin/IRubyObject' }
  Bytecode:
    0x0000000: 0000 2a2b 2d12 1212 1312 1212 1212 1401
    0x0000010: b800 1a2d 0303 0312 12b8 001e 3a08 2a19
    0x0000020: 08b2 0024 b800 2a9a 0010 002a b800 3f3a
    0x0000030: 092a b800 3f3a 0800 2a19 0819 09b8 0043
    0x0000040: 3a0a 190a b0bf                         
  Stackmap Table:
    append_frame(@55,Top,Object[#87])
    full_frame(@69,{},{Object[#89]})

    at java.lang.Class.getDeclaredFields0(Native Method)
    at java.lang.Class.privateGetDeclaredFields(Class.java:2583)
    at java.lang.Class.getField0(Class.java:2975)
    at java.lang.Class.getField(Class.java:1701)
    at org.jruby.ir.targets.JVMVisitor.defineFromBytecode(JVMVisitor.java:101)
    at org.jruby.ir.Compiler.execute(Compiler.java:54)
    ... 11 more

cc @subbuss @enebo

@headius headius added this to the JRuby 9.1.6.0 milestone Oct 26, 2016
@headius
Member
headius commented Oct 26, 2016

I have a PR coming.

@headius headius added a commit to headius/jruby that referenced this issue Oct 26, 2016
@headius headius Also perform uninitialized check on temp locals.
Fixes #4251.
67c0c7d
@headius headius added a commit to headius/jruby that referenced this issue Oct 31, 2016
@headius headius Also perform uninitialized check on temp locals.
Fixes #4251.
e50ec79
@headius headius added a commit to headius/jruby that referenced this issue Oct 31, 2016
@headius headius Also perform uninitialized check on temp locals.
Fixes #4251.
fe0157d
@headius headius added a commit to headius/jruby that referenced this issue Oct 31, 2016
@headius headius Also perform uninitialized check on temp locals.
Fixes #4251.
061764e
@headius headius closed this in #4252 Oct 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment