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

ArrayIndexOutOfBoundsException in Joni #5368

chrisseaton opened this issue Oct 14, 2018 · 4 comments

ArrayIndexOutOfBoundsException in Joni #5368

chrisseaton opened this issue Oct 14, 2018 · 4 comments


Copy link

chrisseaton commented Oct 14, 2018


Provide at least:

  • JRuby version (jruby -v) and command line (flags, JRUBY_OPTS, etc): jruby (2.5.0) 2018-10-14 d2bc2bc Java HotSpot(TM) 64-Bit Server VM 25.161-b12 on 1.8.0_161-b12 +jit [darwin-x86_64]
  • Operating system and platform (e.g. uname -a) Darwin 18.0.0 Darwin Kernel Version 18.0.0: Wed Aug 22 20:13:40 PDT 2018; root:xnu-4903.201.2~1/RELEASE_X86_64 x86_64

Other relevant info you may wish to add:

  • Installed or activated gems: none
  • Application/framework version (e.g. Rails, Sinatra): none
  • Environment variables: none relevant

Expected Behavior

id = 'X6'
double_quoted_rx = /^("|)(.*)\1$/
p id.sub(double_quoted_rx, '')
  • Describe your expectation of how JRuby should behave, perhaps by showing how CRuby/MRI behaves: MRI and JRuby print ""
  • Provide an executable Ruby script or a link to an example repository: as above

Actual Behavior

  • Describe or show the actual behavior: java.lang.ArrayIndexOutOfBoundsException: 2
  • Provide text or screen capture showing the behavior:
Unhandled Java exception: java.lang.ArrayIndexOutOfBoundsException: 2
java.lang.ArrayIndexOutOfBoundsException: 2
          opEndLineSb at org/joni/
            executeSb at org/joni/
              matchAt at org/joni/
           matchCheck at org/joni/
         searchCommon at org/joni/
               search at org/joni/
        matcherSearch at org/jruby/
         subBangMatch at org/jruby/
        subBangNoIter at org/jruby/
             sub_bang at org/jruby/
                  sub at org/jruby/
                 call at org/jruby/RubyString$INVOKER$i$sub.gen:-1
                 call at org/jruby/internal/runtime/methods/
         cacheAndCall at org/jruby/runtime/callsite/
                 call at org/jruby/runtime/callsite/
     invokeOther4:sub at test.rb:3
               <main> at test.rb:3
  invokeWithArguments at java/lang/invoke/
                 load at org/jruby/ir/
            runScript at org/jruby/
          runNormally at org/jruby/
          runNormally at org/jruby/
          runFromMain at org/jruby/
        doRunFromMain at org/jruby/
          internalRun at org/jruby/
                  run at org/jruby/
                 main at org/jruby/

TruffleRuby has the same exception when trying to use Joni 2.1.24. I'd open the issue there, but the only way I know to demonstrate it without tying it to TruffleRuby's code base is from JRuby.

CC @lopex who I think did the update to 2.1.24.

Copy link

lopex commented Oct 14, 2018

Fixed in jruby/joni@6d1b49f, endBeginLineSb might affected the same way. Will look at it.

Copy link
Contributor Author

Thanks very much. Where are we in the Joni release cycle? When will this commit be in a release?

Copy link

lopex commented Oct 14, 2018

2.1.25 is released, waiting for sonatype to propagate.

Copy link
Contributor Author

Thanks that works. I've added a spec to TruffleRuby (not yet mirrored, sorry) that will be upstreamed so you'll get that as a Ruby-level regression test in the future.

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

No branches or pull requests

3 participants