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

jrubyc blows with NPE #2840

Closed
MSNexploder opened this Issue Apr 16, 2015 · 14 comments

Comments

Projects
None yet
2 participants
@MSNexploder
Copy link
Contributor

MSNexploder commented Apr 16, 2015

cat test.rb

puts 'test'
jrubyc --verbose test.rb

Compiling test.rb
java/lang/reflect/Method.java:497:in `invoke': java.lang.NullPointerException
    from /Users/stefan/projects/jruby/lib/ruby/stdlib/jruby/compiler.rb:162:in `block in compile_files_with_options'
    from org/jruby/RubyProc.java:310:in `call'
    from /Users/stefan/projects/jruby/lib/ruby/stdlib/jruby/compiler.rb:236:in `block in compile_files_with_options'
    from org/jruby/RubyArray.java:1570:in `each'
    from /Users/stefan/projects/jruby/lib/ruby/stdlib/jruby/compiler.rb:220:in `compile_files_with_options'
    from /Users/stefan/projects/jruby/lib/ruby/stdlib/jruby/compiler.rb:94:in `compile_argv'
    from /Users/stefan/projects/jruby/bin/jrubyc:5:in `<top>'
jruby -v

jruby 9.0.0.0-SNAPSHOT (2.2.1) 2015-04-16 245cad9 Java HotSpot(TM) 64-Bit Server VM 25.40-b25 on 1.8.0_40-b25 +jit [darwin-x86_64]

@enebo enebo added this to the 9.0.0.0.pre2 milestone Apr 17, 2015

@enebo enebo added the ir label Apr 17, 2015

@enebo

This comment has been minimized.

Copy link
Member

enebo commented Apr 17, 2015

I have this fixed in some local work I have been doing. It should land today.

@MSNexploder

This comment has been minimized.

Copy link
Contributor Author

MSNexploder commented Apr 17, 2015

💖 great!! 💖

@enebo

This comment has been minimized.

Copy link
Member

enebo commented Apr 17, 2015

Fixed in commit b856bd9. Should be fine now.

@enebo enebo closed this Apr 17, 2015

@MSNexploder

This comment has been minimized.

Copy link
Contributor Author

MSNexploder commented Apr 17, 2015

On d2ea85f this still blows if --debug is added to JRUBY_OPTS.

jruby -v

jruby 9.0.0.0-SNAPSHOT (2.2.1) 2015-04-17 d2ea85f Java HotSpot(TM) 64-Bit Server VM 25.40-b25 on 1.8.0_40-b25 +jit [darwin-x86_64]
jrubyc --verbose test.rb

Compiling test.rb
JRUBY_OPTS="--debug" jrubyc --verbose test.rb

Compiling test.rb
java/lang/reflect/Method.java:497:in `invoke': java.lang.NullPointerException
    from /Users/stefan/Desktop/projects/jruby/lib/ruby/stdlib/jruby/compiler.rb:162:in `block in compile_files_with_options'
    from org/jruby/RubyProc.java:303:in `call'
    from /Users/stefan/Desktop/projects/jruby/lib/ruby/stdlib/jruby/compiler.rb:236:in `block in compile_files_with_options'
    from org/jruby/RubyArray.java:1571:in `each'
    from /Users/stefan/Desktop/projects/jruby/lib/ruby/stdlib/jruby/compiler.rb:220:in `compile_files_with_options'
    from /Users/stefan/Desktop/projects/jruby/lib/ruby/stdlib/jruby/compiler.rb:94:in `compile_argv'
    from /Users/stefan/Desktop/projects/jruby/bin/jrubyc:5:in `<top>'
@enebo

This comment has been minimized.

Copy link
Member

enebo commented Apr 17, 2015

Ah ok. This is because we are no properly emitting TRACE instructions which --debug instruments into your source.

enebo added a commit that referenced this issue Apr 17, 2015

Follow up fix to #2840. TraceInstr was missing decode(). String was e…
…ncode/decode needed ability

to deal with null.
@enebo

This comment has been minimized.

Copy link
Member

enebo commented Apr 17, 2015

@MSNexploder ok somewhat unexpected and partially forgotten use case. when you AOT or use IR persistence (which AOT is now implemented with) it will also save instrumented trace instrs. I obviously knew about it because I had a FIXME but I never thought about its usage with AOT itself.

Not sure if we should allow this or we should just omit emitting these when we generate our save format. For now they are in there. If you load this class and have set_trance_func you will see debugging from the AOT'd class.

@MSNexploder

This comment has been minimized.

Copy link
Contributor Author

MSNexploder commented Apr 17, 2015

Not really sure about emitting trace instrs...
Having a (mostly) dev centered ENV setting (silently) change the way code is AOT'd sounds a bit off to me - e.g. I added --debug in my .zshrc and completely forgot about it.

Maybe display some sort of warning / hint?

@MSNexploder

This comment has been minimized.

Copy link
Contributor Author

MSNexploder commented Apr 17, 2015

Meanwhile, I found another one

jruby -v

jruby 9.0.0.0-SNAPSHOT (2.2.2) 2015-04-17 1009f65 Java HotSpot(TM) 64-Bit Server VM 25.45-b02 on 1.8.0_45-b14 +jit [darwin-x86_64]
cat test.rb

class Test
  VERSION = '1.0.0'
  def self.hello
    puts "Hello World!"
  end
end
jrubyc --verbose test.rb 

Compiling test.rb
java/lang/reflect/Method.java:497:in `invoke': java.lang.NullPointerException
    from /Users/stefan/Desktop/projects/jruby/lib/ruby/stdlib/jruby/compiler.rb:162:in `block in compile_files_with_options'
    from org/jruby/RubyProc.java:303:in `call'
    from /Users/stefan/Desktop/projects/jruby/lib/ruby/stdlib/jruby/compiler.rb:236:in `block in compile_files_with_options'
    from org/jruby/RubyArray.java:1571:in `each'
    from /Users/stefan/Desktop/projects/jruby/lib/ruby/stdlib/jruby/compiler.rb:220:in `compile_files_with_options'
    from /Users/stefan/Desktop/projects/jruby/lib/ruby/stdlib/jruby/compiler.rb:94:in `compile_argv'
    from /Users/stefan/Desktop/projects/jruby/bin/jrubyc:5:in `<top>'
    from java/lang/invoke/MethodHandle.java:625:in `invokeWithArguments'
@enebo

This comment has been minimized.

Copy link
Member

enebo commented Apr 18, 2015

Fixed in 79ed302.

@MSNexploder

This comment has been minimized.

Copy link
Contributor Author

MSNexploder commented Apr 18, 2015

Found another one. This time it's file_test.rb from rubyzip (https://github.com/rubyzip/rubyzip/blob/002959f2e/test/file_test.rb).
I tried creating a more reduced sample, but apparently randomly removing a few methods gets everything compiled.

jruby 9.0.0.0-SNAPSHOT (2.2.2) 2015-04-18 79ed302 Java HotSpot(TM) 64-Bit Server VM 25.45-b02 on 1.8.0_45-b14 +jit [darwin-x86_64]
@enebo

This comment has been minimized.

Copy link
Member

enebo commented Apr 18, 2015

Is the error you get this:

org/jruby/compiler/impl/SkinnyMethodAdapter.java:126:in `ldc': java.lang.IllegalArgumentException

Could you give me a complete command-line for this. I find this particular error strange as I would not expect jrubyc to end up with a bytecode error unless perhaps a code block ran into a bytecode limit?

@enebo

This comment has been minimized.

Copy link
Member

enebo commented Apr 18, 2015

I should point out I am passing JRUBY_OPTS="-d -Xbacktrace.style=raw" to get real offending backtrace.

@MSNexploder

This comment has been minimized.

Copy link
Contributor Author

MSNexploder commented Apr 18, 2015

Removing one of the longer methods / a few shorter ones "fixes" the compilation. Regardless of the actual methods removed.

Complete stacktrace:

JRUBY_OPTS="-d -Xbacktrace.style=raw" jrubyc --verbose file_test.rb

/Users/stefan/Desktop/projects/jruby/lib/ruby/stdlib/jruby/compiler.rb:229: warning: shadowing outer local variable - filename
Compiling file_test.rb
org/jruby/compiler/impl/SkinnyMethodAdapter.java:126:in `ldc': java.lang.IllegalArgumentException
    from sun/reflect/NativeMethodAccessorImpl.java:-2:in `invoke0'
    from sun/reflect/NativeMethodAccessorImpl.java:62:in `invoke'
    from sun/reflect/DelegatingMethodAccessorImpl.java:43:in `invoke'
    from java/lang/reflect/Method.java:497:in `invoke'
    from org/jruby/javasupport/JavaMethod.java:457:in `invokeDirectWithExceptionHandling'
    from org/jruby/javasupport/JavaMethod.java:318:in `invokeDirect'
    from org/jruby/java/invokers/InstanceMethodInvoker.java:45:in `call'
    from org/jruby/runtime/callsite/CachingCallSite.java:313:in `cacheAndCall'
    from org/jruby/runtime/callsite/CachingCallSite.java:163:in `call'
    from org/jruby/ir/interpreter/InterpreterEngine.java:290:in `processCall'
    from org/jruby/ir/interpreter/StartupInterpreterEngine.java:76:in `interpret'
    from org/jruby/ir/interpreter/Interpreter.java:137:in `INTERPRET_BLOCK'
    from org/jruby/runtime/InterpretedIRBlockBody.java:109:in `commonYieldPath'
    from org/jruby/runtime/IRBlockBody.java:69:in `call'
    from org/jruby/runtime/Block.java:106:in `call'
    from org/jruby/RubyProc.java:319:in `call'
    from org/jruby/RubyProc.java:303:in `call19'
    from org/jruby/internal/runtime/methods/DynamicMethod.java:209:in `call'
    from org/jruby/internal/runtime/methods/DynamicMethod.java:205:in `call'
    from org/jruby/runtime/callsite/CachingCallSite.java:313:in `cacheAndCall'
    from org/jruby/runtime/callsite/CachingCallSite.java:163:in `call'
    from org/jruby/ir/interpreter/InterpreterEngine.java:290:in `processCall'
    from org/jruby/ir/interpreter/StartupInterpreterEngine.java:76:in `interpret'
    from org/jruby/ir/interpreter/Interpreter.java:137:in `INTERPRET_BLOCK'
    from org/jruby/runtime/InterpretedIRBlockBody.java:109:in `commonYieldPath'
    from org/jruby/runtime/IRBlockBody.java:138:in `doYield'
    from org/jruby/runtime/BlockBody.java:85:in `yield'
    from org/jruby/runtime/Block.java:147:in `yield'
    from org/jruby/RubyArray.java:1571:in `each'
    from org/jruby/internal/runtime/methods/JavaMethod.java:473:in `call'
    from org/jruby/runtime/callsite/CachingCallSite.java:273:in `cacheAndCall'
    from org/jruby/runtime/callsite/CachingCallSite.java:79:in `callBlock'
    from org/jruby/runtime/callsite/CachingCallSite.java:83:in `call'
    from org/jruby/ir/instructions/CallBase.java:419:in `interpret'
    from org/jruby/ir/interpreter/InterpreterEngine.java:322:in `processCall'
    from org/jruby/ir/interpreter/StartupInterpreterEngine.java:76:in `interpret'
    from org/jruby/internal/runtime/methods/MixedModeIRMethod.java:132:in `INTERPRET_METHOD'
    from org/jruby/internal/runtime/methods/MixedModeIRMethod.java:118:in `call'
    from org/jruby/internal/runtime/methods/WrapperMethod.java:90:in `call'
    from org/jruby/runtime/callsite/CachingCallSite.java:273:in `cacheAndCall'
    from org/jruby/runtime/callsite/CachingCallSite.java:79:in `callBlock'
    from org/jruby/runtime/callsite/CachingCallSite.java:83:in `call'
    from org/jruby/ir/instructions/CallBase.java:419:in `interpret'
    from org/jruby/ir/interpreter/InterpreterEngine.java:322:in `processCall'
    from org/jruby/ir/interpreter/StartupInterpreterEngine.java:76:in `interpret'
    from org/jruby/ir/interpreter/InterpreterEngine.java:84:in `interpret'
    from org/jruby/internal/runtime/methods/MixedModeIRMethod.java:202:in `INTERPRET_METHOD'
    from org/jruby/internal/runtime/methods/MixedModeIRMethod.java:188:in `call'
    from org/jruby/internal/runtime/methods/DynamicMethod.java:205:in `call'
    from org/jruby/internal/runtime/methods/WrapperMethod.java:58:in `call'
    from org/jruby/runtime/callsite/CachingCallSite.java:313:in `cacheAndCall'
    from org/jruby/runtime/callsite/CachingCallSite.java:163:in `call'
    from /Users/stefan/Desktop/projects/jruby/bin/jrubyc:5:in `<top>'
    from java/lang/invoke/MethodHandle.java:625:in `invokeWithArguments'
    from org/jruby/ir/Compiler.java:111:in `load'
    from org/jruby/Ruby.java:828:in `runScript'
    from org/jruby/Ruby.java:821:in `runScript'
    from org/jruby/Ruby.java:751:in `runNormally'
    from org/jruby/Ruby.java:573:in `runFromMain'
    from org/jruby/Main.java:404:in `doRunFromMain'
    from org/jruby/Main.java:299:in `internalRun'
    from org/jruby/Main.java:226:in `run'
    from org/jruby/Main.java:198:in `main'
@enebo

This comment has been minimized.

Copy link
Member

enebo commented Apr 19, 2015

@MSNexploder I might leave this for @headius on Monday. This I think is even an open issue for this impl of AOT (I don't see if off-hand). compiler.rb makes a String and then saves it but it does not check the string's length. In the case you are compiling something which emits more than a 32k byte string which cannot fit into a Java string literal. The solution is not super tough. We just need to break this IR compiled output into n <32k byte strings and concat them as part of bootstrapping this AOT output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.