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

Closed
chrisseaton opened this Issue Oct 14, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@chrisseaton
Copy link
Contributor

commented Oct 14, 2018

Environment

Provide at least:

  • JRuby version (jruby -v) and command line (flags, JRUBY_OPTS, etc): jruby 9.2.1.0-SNAPSHOT (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 dhcp-10-175-223-212.vpn.oracle.com 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 9.2.0.0 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/ByteCodeMachine.java:1276
            executeSb at org/joni/ByteCodeMachine.java:369
              matchAt at org/joni/ByteCodeMachine.java:167
           matchCheck at org/joni/Matcher.java:287
         searchCommon at org/joni/Matcher.java:460
               search at org/joni/Matcher.java:301
        matcherSearch at org/jruby/RubyRegexp.java:231
         subBangMatch at org/jruby/RubyString.java:2966
        subBangNoIter at org/jruby/RubyString.java:2930
             sub_bang at org/jruby/RubyString.java:2884
                  sub at org/jruby/RubyString.java:2864
                 call at org/jruby/RubyString$INVOKER$i$sub.gen:-1
                 call at org/jruby/internal/runtime/methods/JavaMethod.java:421
         cacheAndCall at org/jruby/runtime/callsite/CachingCallSite.java:365
                 call at org/jruby/runtime/callsite/CachingCallSite.java:201
     invokeOther4:sub at test.rb:3
               <main> at test.rb:3
  invokeWithArguments at java/lang/invoke/MethodHandle.java:627
                 load at org/jruby/ir/Compiler.java:94
            runScript at org/jruby/Ruby.java:852
          runNormally at org/jruby/Ruby.java:771
          runNormally at org/jruby/Ruby.java:789
          runFromMain at org/jruby/Ruby.java:601
        doRunFromMain at org/jruby/Main.java:415
          internalRun at org/jruby/Main.java:307
                  run at org/jruby/Main.java:234
                 main at org/jruby/Main.java:206

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.

@lopex

This comment has been minimized.

Copy link
Member

commented Oct 14, 2018

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

@chrisseaton

This comment has been minimized.

Copy link
Contributor Author

commented Oct 14, 2018

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

@lopex

This comment has been minimized.

Copy link
Member

commented Oct 14, 2018

2.1.25 is released, waiting for sonatype to propagate.

@chrisseaton

This comment has been minimized.

Copy link
Contributor Author

commented Oct 14, 2018

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.

lopex added a commit to jruby/joni that referenced this issue Oct 15, 2018

@enebo enebo added this to the JRuby 9.2.1.0 milestone Nov 1, 2018

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.