Skip to content

Zlib crc32 resulting into Java::JavaLang::ArrayIndexOutOfBoundsException (32) #5290

@vipulnsward

Description

@vipulnsward

After https://github.com/jruby/jruby/pull/5088/files was merged:

irb(main):027:0> n =  "p" ; key = ~305419896
=> -305419897
irb(main):028:0> Zlib.crc32(n, key)
Traceback (most recent call last):
       16: from org.jruby.RubyKernel.eval19(RubyKernel.java:1037)
       15: from org.jruby.RubyKernel.evalCommon(RubyKernel.java:1070)
       14: from org.jruby.ir.interpreter.Interpreter.evalWithBinding(Interpreter.java:197)
       13: from org.jruby.ir.interpreter.Interpreter.evalCommon(Interpreter.java:173)
       12: from org.jruby.ir.interpreter.Interpreter.INTERPRET_EVAL(Interpreter.java:119)
       11: from org.jruby.ir.interpreter.StartupInterpreterEngine.interpret(StartupInterpreterEngine.java:72)
       10: from org.jruby.ir.interpreter.InterpreterEngine.processCall(InterpreterEngine.java:324)
        9: from org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:201)
        8: from org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:365)
        7: from org.jruby.internal.runtime.methods.DynamicMethod.call(DynamicMethod.java:210)
        6: from org.jruby.internal.runtime.methods.JavaMethod$JavaMethodN.call(JavaMethod.java:801)
        5: from org.jruby.ext.zlib.RubyZlib$INVOKER$s$0$2$crc32.call(RubyZlib$INVOKER$s$0$2$crc32.gen)
        4: from org.jruby.ext.zlib.RubyZlib.crc32(RubyZlib.java:206)
        3: from com.jcraft.jzlib.JZlib.crc32_combine(JZlib.java:90)
        2: from com.jcraft.jzlib.CRC32.combine(CRC32.java:108)
        1: from com.jcraft.jzlib.CRC32.gf2_matrix_times(CRC32.java:134)
Java::JavaLang::ArrayIndexOutOfBoundsException (32)

This passes successfully on ruby 2.5.1 as:

irb(main):010:0> n =  "p" ; key = ~305419896
=> -305419897
irb(main):011:0> Zlib.crc32(n, key)
=> 4046865307

Related on why ruby seems to allows this: ruby/ruby@778796b

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