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

java.lang.NullPointerException when using for loops #3545

Closed
vassilios opened this issue Dec 17, 2015 · 2 comments
Closed

java.lang.NullPointerException when using for loops #3545

vassilios opened this issue Dec 17, 2015 · 2 comments
Labels
Milestone

Comments

@vassilios
Copy link

@vassilios vassilios commented Dec 17, 2015

I was trying to port some legacy code to jruby 9.0.4.0 when I came across this issue.

Attaching backtrace of exception.
The following repository should help you reproduce the problem.

https://github.com/vassilios/test_for_loop/tree/master

Running

bin/rspec --format doc

Fails with a null pointer exception.

Tested on ubuntu linux with jruby 9.0.4.0

$ uname -a
Linux ip-172-30-3-223 3.13.0-36-generic #63-Ubuntu SMP Wed Sep 3 21:30:07 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

$ jruby -v
jruby 9.0.4.0 (2.2.2) 2015-11-12 b9fb7aa OpenJDK 64-Bit Server VM 24.79-b02 on 1.7.0_79-b14 +jit [linux-amd64]

test_for_loop.txt

kares added a commit that referenced this issue Jan 18, 2017
@kares
Copy link
Member

@kares kares commented Jan 18, 2017

Thanks Vassilis, have extracted a failing piece into JRuby's internal specs - fails just the same.
Someone should look at this soon (bin/jruby -S rake spec:regression SPEC_OPTS="-e 3545")

       expected no Exception, got java.lang.NullPointerException with backtrace:
         # org.jruby.ir.operands.CurrentScope.retrieve(CurrentScope.java:71)
         # org.jruby.ir.instructions.SearchConstInstr.cache(SearchConstInstr.java:82)
         # org.jruby.ir.interpreter.StartupInterpreterEngine.processOtherOp(StartupInterpreterEngine.java:169)
         # org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:111)
         # org.jruby.ir.interpreter.Interpreter.INTERPRET_BLOCK(Interpreter.java:132)
         # org.jruby.runtime.InterpretedIRBlockBody.commonYieldPath(InterpretedIRBlockBody.java:141)
         # org.jruby.runtime.IRBlockBody.doYield(IRBlockBody.java:182)
         # org.jruby.runtime.BlockBody.yield(BlockBody.java:111)
         # org.jruby.runtime.Block.yield(Block.java:167)
         # org.jruby.RubyInteger.fixnumUpto(RubyInteger.java:159)
         # org.jruby.RubyInteger.upto(RubyInteger.java:134)
         # org.jruby.RubyInteger$INVOKER$i$1$0$upto.call(RubyInteger$INVOKER$i$1$0$upto.gen)
         # org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:348)
         # org.jruby.runtime.callsite.CachingCallSite.callBlock(CachingCallSite.java:173)
         # org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:177)
         # org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:332)
         # org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:73)
         # org.jruby.ir.interpreter.Interpreter.INTERPRET_BLOCK(Interpreter.java:132)
         # org.jruby.runtime.InterpretedIRBlockBody.commonYieldPath(InterpretedIRBlockBody.java:141)
         # org.jruby.runtime.IRBlockBody.doYield(IRBlockBody.java:182)
         # org.jruby.runtime.BlockBody.yield(BlockBody.java:111)
         # org.jruby.runtime.Block.yield(Block.java:167)
         # org.jruby.RubyRange.fixnumEach(RubyRange.java:531)
         # org.jruby.RubyRange.each(RubyRange.java:486)
@kares kares added this to the JRuby 9.1.8.0 milestone Jan 18, 2017
@enebo enebo closed this in 152cf90 Jan 19, 2017
@enebo
Copy link
Member

@enebo enebo commented Jan 19, 2017

Leaving a note on this one. Our JIT ignores the search depth value altogether but in interp we walk down looking for a scope. In this case we were counting for loops as full scopes. Since for loops have no scope this makes no sense so I omit it from the counting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.