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

NPE from within CoverageModule.convertCoverageToRuby #5111

Closed
JasonLunn opened this issue Mar 26, 2018 · 3 comments
Closed

NPE from within CoverageModule.convertCoverageToRuby #5111

JasonLunn opened this issue Mar 26, 2018 · 3 comments

Comments

@JasonLunn
Copy link
Contributor

JasonLunn commented Mar 26, 2018

After stopping my test Tomcat instance, SimpleCov's at_exit hook is attempting to produce a coverage report, but errors out in the process:

cat ~/opt/apache-tomcat-8.5.20/logs/localhost.2018-03-26.log:

26-Mar-2018 11:22:21.678 SEVERE [localhost-startStop-2] org.apache.catalina.core.ApplicationFilterConfig.release Failed to destroy the filter named [RackFilter] of type [org.jruby.rack.RackFilter]
 java.lang.NullPointerException
        at org.jruby.ext.coverage.CoverageModule.convertCoverageToRuby(CoverageModule.java:81)
        at org.jruby.ext.coverage.CoverageModule.result(CoverageModule.java:61)
        at org.jruby.ext.coverage.CoverageModule$INVOKER$s$0$0$result_DBG.call(CoverageModule$INVOKER$s$0$0$result_DBG.gen)
        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:298)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:127)
        at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:344)
        at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:74)
        at org.jruby.ir.interpreter.InterpreterEngine.interpret(InterpreterEngine.java:78)
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.INTERPRET_METHOD(MixedModeIRMethod.java:144)
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:130)
        at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:192)
        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:298)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:127)
        at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:344)
        at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:74)
        at org.jruby.ir.interpreter.Interpreter.INTERPRET_BLOCK(Interpreter.java:132)
        at org.jruby.runtime.MixedModeIRBlockBody.commonYieldPath(MixedModeIRBlockBody.java:148)
        at org.jruby.runtime.IRBlockBody.call(IRBlockBody.java:73)
        at org.jruby.runtime.Block.call(Block.java:124)
        at org.jruby.RubyProc.call(RubyProc.java:289)
        at org.jruby.RubyProc.call19(RubyProc.java:273)
        at org.jruby.RubyProc$INVOKER$i$0$0$call19_DBG.call(RubyProc$INVOKER$i$0$0$call19_DBG.gen)
        at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:196)
        at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:192)
        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:298)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:127)
        at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:344)
        at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:74)
        at org.jruby.ir.interpreter.InterpreterEngine.interpret(InterpreterEngine.java:78)
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.INTERPRET_METHOD(MixedModeIRMethod.java:144)
        at org.jruby.internal.runtime.methods.MixedModeIRMethod.call(MixedModeIRMethod.java:130)
        at org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:192)
        at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:298)
        at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:127)
        at org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:344)
        at org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:74)
        at org.jruby.ir.interpreter.Interpreter.INTERPRET_BLOCK(Interpreter.java:132)
        at org.jruby.runtime.MixedModeIRBlockBody.commonYieldPath(MixedModeIRBlockBody.java:148)
        at org.jruby.runtime.IRBlockBody.call(IRBlockBody.java:73)
        at org.jruby.runtime.Block.call(Block.java:124)
        at org.jruby.RubyProc.call(RubyProc.java:289)
        at org.jruby.RubyProc.call(RubyProc.java:246)
        at org.jruby.Ruby.tearDown(Ruby.java:3229)
        at org.jruby.rack.DefaultRackApplicationFactory$RackApplicationImpl.destroy(DefaultRackApplicationFactory.java:455)
        at org.jruby.rack.DefaultRackApplicationFactory.finishedWithApplication(DefaultRackApplicationFactory.java:125)
        at org.jruby.rack.SharedRackApplicationFactory.destroy(SharedRackApplicationFactory.java:60)
        at org.jruby.rack.DefaultRackDispatcher.destroy(DefaultRackDispatcher.java:74)
        at org.jruby.rack.AbstractFilter.destroy(AbstractFilter.java:77)
        at org.apache.catalina.core.ApplicationFilterConfig.release(ApplicationFilterConfig.java:318)
        at org.apache.catalina.core.StandardContext.filterStop(StandardContext.java:4623)
        at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5421)
        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:226)
        at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1435)
        at org.apache.catalina.core.ContainerBase$StopChild.call(ContainerBase.java:1424)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)

Environment

  • JRuby 9.1.15.0
  • Warbler from master via git
  • Tomcat 8.5.20
  • Java 1.8.0_121-b13
  • macOS High Sierra: Darwin brakebills.home 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64

Other relevant info you may wish to add:

  • SimpleCov 0.16.1
  • Rails 5.0.6
  • RAILS_ENV=test
  • JAVA_OPTS=-Xmx2g -Djruby.debug.fullTrace=true

Expected Behavior

  • I expect SimpleCov to generate a code coverage report without causing an NPE when the JRuby interpreter is spawned by Tomcat / Warbler in a manner similar to how it is able to do so when started from the command line.
@headius
Copy link
Member

headius commented Mar 26, 2018

It looks as this this could happen if a coverage line event is triggered against a source with a null filename, such as might happen evaluating Ruby code through our embedding interface. I'll harden the logic to try to ignore such files.

@headius
Copy link
Member

headius commented Mar 26, 2018

Trivial reproduction:

$ jruby -e 'require "coverage"; Coverage.start; JRuby.runtime.executeScript("1 + 1", nil); Coverage.result'
-e:1: warning: tracing (e.g. set_trace_func) will not capture all events without --debug flag
Unhandled Java exception: java.lang.NullPointerException
java.lang.NullPointerException: null
  convertCoverageToRuby at org/jruby/ext/coverage/CoverageModule.java:81
                 result at org/jruby/ext/coverage/CoverageModule.java:61
                   call at org/jruby/ext/coverage/CoverageModule$INVOKER$s$0$0$result.gen:-1
           cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:298
                   call at org/jruby/runtime/callsite/CachingCallSite.java:127
    invokeOther6:result at -e:1
                 <main> at -e:1
    invokeWithArguments at java/lang/invoke/MethodHandle.java:627
                   load at org/jruby/ir/Compiler.java:94
              runScript at org/jruby/Ruby.java:830
            runNormally at org/jruby/Ruby.java:749
            runNormally at org/jruby/Ruby.java:767
            runFromMain at org/jruby/Ruby.java:580
          doRunFromMain at org/jruby/Main.java:417
            internalRun at org/jruby/Main.java:305
                    run at org/jruby/Main.java:232
                   main at org/jruby/Main.java:204

@JasonLunn
Copy link
Contributor Author

Thanks for the incredibly fast turn around!

kares added a commit to kares/jruby that referenced this issue Mar 27, 2018
* jruby-9.1:
  [fix] cast nsec nanos to long to avoid "overflow" with double value
  Handle this deprecation differently.
  Default to Java 9 bytecode for any java.specification.version>1.8.
  WrapperMethod is still needed for visibility.
  Revert "Finally eliminate use of WrapperMethod."
  Eliminate deprecation warnings in test suite.
  Finally eliminate use of WrapperMethod.
  Fix most deprecated calls.
  Handle error when attempting to connect to IP6 with default INET4.
  Add test_coverage to jruby.index.
  Add test for null filename in coverage. jruby#5111
  Do not attempt to add coverage for null filename. Fixes jruby#5111.
  Add basic specs for Exception#backtrace_locations.
  Exception.backtrace_locations should persist and be mutable.
  Return nil if no backtrace has been captured. Fixes jruby#5099.
  fix for jruby#5086, RegexpError invalid pattern in look-behind for certain Regexps since 9.1.16.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants