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

Unhandled Java exception: java.lang.ArrayIndexOutOfBoundsException: -3 #3591

Closed
andygeers opened this Issue Jan 11, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@andygeers
Copy link

andygeers commented Jan 11, 2016

I am new to JRuby, but I get this error running a script in a Jenkins deployment environment and it looks like it's coming from inside JRuby. Towards the end of this stack trace you see my code: deploy-capacity-manager/vendor/bundle/jruby/2.2.0/bin/ebs-deploy:23 - this is a line that calls load Gem.bin_path('ebs-deploy', 'ebs-deploy', version), and when it runs that I get the following exception (JRuby 9.0.4.0, but also seen with 9.0.1.0):

Unhandled Java exception: java.lang.ArrayIndexOutOfBoundsException: -3
java.lang.ArrayIndexOutOfBoundsException: -3
        run_exec_dup2 at org/jruby/util/io/PopenExecutor.java:789
    execargRunOptions at org/jruby/util/io/PopenExecutor.java:986
         spawnProcess at org/jruby/util/io/PopenExecutor.java:113
        spawnInternal at org/jruby/util/io/PopenExecutor.java:93
             system19 at org/jruby/RubyKernel.java:1541
                 call at org/jruby/internal/runtime/methods/JavaMethod.java:729
         cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:273
            callBlock at org/jruby/runtime/callsite/CachingCallSite.java:79
                 call at org/jruby/runtime/callsite/CachingCallSite.java:83
            interpret at org/jruby/ir/instructions/CallBase.java:419
          processCall at org/jruby/ir/interpreter/InterpreterEngine.java:322
            interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:77
            interpret at org/jruby/ir/interpreter/InterpreterEngine.java:83
     INTERPRET_METHOD at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:197
                 call at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:183
                 call at org/jruby/internal/runtime/methods/DynamicMethod.java:197
         cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:313
                 call at org/jruby/runtime/callsite/CachingCallSite.java:163
          processCall at org/jruby/ir/interpreter/InterpreterEngine.java:290
            interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:77
            interpret at org/jruby/ir/interpreter/InterpreterEngine.java:77
     INTERPRET_METHOD at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:162
                 call at org/jruby/internal/runtime/methods/MixedModeIRMethod.java:148
                 call at org/jruby/internal/runtime/methods/DynamicMethod.java:189
         cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:293
                 call at org/jruby/runtime/callsite/CachingCallSite.java:131
          processCall at org/jruby/ir/interpreter/InterpreterEngine.java:306
            interpret at org/jruby/ir/interpreter/StartupInterpreterEngine.java:77
       INTERPRET_ROOT at org/jruby/ir/interpreter/Interpreter.java:102
              execute at org/jruby/ir/interpreter/Interpreter.java:89
              execute at org/jruby/ir/interpreter/Interpreter.java:32
              execute at org/jruby/ir/IRTranslator.java:42
       runInterpreter at org/jruby/Ruby.java:837
             loadFile at org/jruby/Ruby.java:2900
                 load at org/jruby/runtime/load/LibrarySearcher.java:236
                 load at org/jruby/runtime/load/LibrarySearcher.java:35
                 load at org/jruby/runtime/load/LoadService.java:336
           loadCommon at org/jruby/RubyKernel.java:965
               load19 at org/jruby/RubyKernel.java:957
                 call at org/jruby/internal/runtime/methods/DynamicMethod.java:201
                 call at org/jruby/internal/runtime/methods/DynamicMethod.java:197
         cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:313
                 call at org/jruby/runtime/callsite/CachingCallSite.java:163
                <top> at /var/lib/jenkins/workspace/Deploy/deploy-capacity-manager/vendor/bundle/jruby/2.2.0/bin/ebs-deploy:23
  invokeWithArguments at java/lang/invoke/MethodHandle.java:599
                 load at org/jruby/ir/Compiler.java:111
            runScript at org/jruby/Ruby.java:821
            runScript at org/jruby/Ruby.java:813
          runNormally at org/jruby/Ruby.java:751
          runFromMain at org/jruby/Ruby.java:573
        doRunFromMain at org/jruby/Main.java:409
          internalRun at org/jruby/Main.java:304
                  run at org/jruby/Main.java:233
                 main at org/jruby/Main.java:200
@kares

This comment has been minimized.

Copy link
Member

kares commented Jan 11, 2016

the code assumes Java's binarySeach returns -1 when not found https://github.com/jruby/jruby/blob/master/core/src/main/java/org/jruby/util/io/PopenExecutor.java#L784 ... should be checking for any < 0 value as invalid. this is an easy fix.

@kares kares added this to the JRuby 9.0.5.0 milestone Jan 11, 2016

@andygeers

This comment has been minimized.

Copy link
Author

andygeers commented Jan 11, 2016

Yes, a bit of experimentation suggests the actual command it executes isn't that important - the key bit is that it's a command that exits with a failure code

kares added a commit that referenced this issue Jan 11, 2016

@kares kares closed this Jan 11, 2016

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.