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

Scan ArrayIndexOutOfBoundsException Error #5036

Closed
sebastianguarin opened this issue Feb 8, 2018 · 1 comment
Closed

Scan ArrayIndexOutOfBoundsException Error #5036

sebastianguarin opened this issue Feb 8, 2018 · 1 comment
Assignees
Labels

Comments

@sebastianguarin
Copy link

sebastianguarin commented Feb 8, 2018

Environment

  • jruby-9.1.13.0
  • rails 4.2.9
  • Darwin 14.5.0 Darwin Kernel Version 14.5.0: Sun Jun 4 21:40:08 PDT 2017; root:xnu-2782.70.3~1/RELEASE_X86_64 x86_64

Helper method

"#{c1}....#{c2}........" is a random string, which used to be an english sentence but most of the characters were replaced with dots. However the issue is not raised if C1 and C2 are dots ..
The arg 'string' was generated randomly but it only raises an Exception in certain conditions which are unknown

def jruby_scan_error(string)
  ('a'..'z').to_a.each do |c1|
    ('a'..'z').to_a.each do |c2|
      begin
        # Downcase is necessary to raise the issue
        string.downcase.scan("#{c1}....#{c2}........")
      rescue Exception => e
        puts "c1: #{c1}\tc2: #{c2}\tError: #{e.class}:#{e.message}"
      end
    end
  end
end

Expected Behavior

  • The following occurs in MRI ruby:
jruby_scan_error("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")
=> nil

Actual Behavior

  • In Jruby-9.1.15.0:
jruby_scan_error("abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz")

c1: d c2: r Error: Java::JavaLang::ArrayIndexOutOfBoundsException:52
c1: m c2: d Error: Java::JavaLang::ArrayIndexOutOfBoundsException:52
c1: m c2: o Error: Java::JavaLang::ArrayIndexOutOfBoundsException:52
c1: o c2: c Error: Java::JavaLang::ArrayIndexOutOfBoundsException:52
c1: o c2: r Error: Java::JavaLang::ArrayIndexOutOfBoundsException:52
c1: x c2: o Error: Java::JavaLang::ArrayIndexOutOfBoundsException:52

Backtrace

Java::JavaLang::ArrayIndexOutOfBoundsException: 52
	from org.jruby.util.StringSupport.rb_memsearch_qs_utf8_hash(StringSupport.java:2307)
	from org.jruby.util.StringSupport.rb_memsearch_qs_utf8(StringSupport.java:2346)
	from org.jruby.util.StringSupport.memsearch(StringSupport.java:1851)
	from org.jruby.RubyString.strseqIndex(RubyString.java:2757)
	from org.jruby.RubyString.patternSearch(RubyString.java:3881)
	from org.jruby.RubyString.scanOnce(RubyString.java:3841)
	from org.jruby.RubyString.scan19(RubyString.java:3809)
	from org.jruby.RubyString$INVOKER$i$1$0$scan19.call(RubyString$INVOKER$i$1$0$scan19.gen)
	from org.jruby.internal.runtime.methods.JavaMethod$JavaMethodOneOrNBlock.call(JavaMethod.java:384)
	from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:338)
	from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:163)
	from org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:314)
	from org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:73)
	from org.jruby.ir.interpreter.Interpreter.INTERPRET_EVAL(Interpreter.java:122)
	from org.jruby.ir.interpreter.Interpreter.evalCommon(Interpreter.java:176)
	from org.jruby.ir.interpreter.Interpreter.evalWithBinding(Interpreter.java:200)
... 160 levels...
	from org.jruby.internal.runtime.methods.JavaMethod$JavaMethodOneOrNBlock.call(JavaMethod.java:384)
	from org.jruby.internal.runtime.methods.AliasMethod.call(AliasMethod.java:61)
	from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:338)
	from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:163)
	from bin.rails.invokeOther5:require(bin/rails:4)
	from bin.rails.RUBY$script(bin/rails:4)
	from java.lang.invoke.MethodHandle.invokeWithArguments(MethodHandle.java:625)
	from org.jruby.ir.Compiler$1.load(Compiler.java:95)
	from org.jruby.Ruby.runScript(Ruby.java:828)
	from org.jruby.Ruby.runNormally(Ruby.java:747)
	from org.jruby.Ruby.runNormally(Ruby.java:765)
	from org.jruby.Ruby.runFromMain(Ruby.java:578)
	from org.jruby.Main.doRunFromMain(Main.java:417)
	from org.jruby.Main.internalRun(Main.java:305)
	from org.jruby.Main.run(Main.java:232)
	from org.jruby.Main.main(Main.java:204)
@kares kares added this to the JRuby 9.1.16.0 milestone Feb 8, 2018
@kares kares added the core label Feb 8, 2018
@kares kares self-assigned this Feb 8, 2018
@headius
Copy link
Member

headius commented Feb 13, 2018

Will be fixed by #5037.

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

No branches or pull requests

3 participants