Skip to content

ArrayIndexOutOfBoundsException in Joni #5368

@chrisseaton

Description

@chrisseaton

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions