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 parsing class file #112

Closed
rossabaker opened this issue Mar 30, 2016 · 12 comments
Closed

ArrayIndexOutOfBoundsException parsing class file #112

rossabaker opened this issue Mar 30, 2016 · 12 comments
Milestone

Comments

@rossabaker
Copy link
Contributor

I'm getting an ArrayIndexOutOfBoundsException out of MiMa (link to full error):

java.lang.ArrayIndexOutOfBoundsException: 1515
    at com.typesafe.tools.mima.core.BufferReader.nextByte(BufferReader.scala:33)
    at com.typesafe.tools.mima.core.BufferReader.nextChar(BufferReader.scala:48)
    at com.typesafe.tools.mima.core.ClassfileParser.parseMembers(ClassfileParser.scala:216)
    at com.typesafe.tools.mima.core.ClassfileParser.parseFields(ClassfileParser.scala:208)
    at com.typesafe.tools.mima.core.ClassfileParser.parseClass(ClassfileParser.scala:261)
    at com.typesafe.tools.mima.core.ClassfileParser.parseAll(ClassfileParser.scala:68)
    at com.typesafe.tools.mima.core.ClassfileParser.parse(ClassfileParser.scala:59)

The offending jar file is http4s-jawn_2.11-0.13.0a, and the mima version is 0.1.9.

I found a similar issue, but not an answer. Any idea what might be going on here? Thanks!

@dotta
Copy link
Contributor

dotta commented Mar 31, 2016

Thanks for reporting. Would be great to isolate the issue and add a test to the regression suite before fixing it. Contribution welcomed! :-)

@fthomas
Copy link

fthomas commented Apr 25, 2016

I've seen a similar issue here: fthomas/refined#154. The problem went away after running mimaReportBinaryIssues before sbt-scoverage's coverage in the CI build.

@milessabin
Copy link

I'm also seeing it in macro-compat.

@wsargent
Copy link

wsargent commented Jun 3, 2016

We're also seeing it in Play builds: https://travis-ci.org/playframework/playframework/jobs/134935906#L613

java.lang.ArrayIndexOutOfBoundsException: 66581
    at com.typesafe.tools.mima.core.BufferReader.nextByte(BufferReader.scala:33)
    at com.typesafe.tools.mima.core.BufferReader.nextInt(BufferReader.scala:53)
    at com.typesafe.tools.mima.core.ClassfileParser$$anonfun$parseAttributes$2.apply$mcVI$sp(ClassfileParser.scala:298)
    at scala.collection.immutable.Range.foreach$mVc$sp(Range.scala:141)
    at com.typesafe.tools.mima.core.ClassfileParser.parseAttributes(ClassfileParser.scala:295)
    at com.typesafe.tools.mima.core.ClassfileParser.parseMember(ClassfileParser.scala:240)
    at com.typesafe.tools.mima.core.ClassfileParser$$anonfun$parseMembers$1.apply(ClassfileParser.scala:223)
    at com.typesafe.tools.mima.core.ClassfileParser$$anonfun$parseMembers$1.apply(ClassfileParser.scala:218)
    at scala.collection.immutable.Range.foreach(Range.scala:141)
    at com.typesafe.tools.mima.core.ClassfileParser.parseMembers(ClassfileParser.scala:218)
    at com.typesafe.tools.mima.core.ClassfileParser.parseMethods(ClassfileParser.scala:212)
    at com.typesafe.tools.mima.core.ClassfileParser.parseClass(ClassfileParser.scala:262)
    at com.typesafe.tools.mima.core.ClassfileParser.parseAll(ClassfileParser.scala:68)
    at com.typesafe.tools.mima.core.ClassfileParser.parse(ClassfileParser.scala:59)
    at com.typesafe.tools.mima.core.ClassInfo.ensureLoaded(ClassInfo.scala:86)
    at com.typesafe.tools.mima.core.ClassInfo.methods(ClassInfo.scala:101)
    at com.typesafe.tools.mima.core.ClassInfo$$anonfun$lookupClassMethods$2.apply(ClassInfo.scala:123)
    at com.typesafe.tools.mima.core.ClassInfo$$anonfun$lookupClassMethods$2.apply(ClassInfo.scala:123)

@wsargent
Copy link

wsargent commented Jun 3, 2016

It looks like the BufferReader is reading past the end of the array that's passed in. I'll add some checks.

@wsargent
Copy link

wsargent commented Jun 3, 2016

One thing that stands out is that in nextBytes the index pointer is being updated before the call to slice, and then buf.slice() will only slice up to the length of the actual array:

  def nextBytes(len: Int): Array[Byte] = {
    bp += len
    buf.slice(bp - len, bp)
  }

https://github.com/typesafehub/migration-manager/blob/master/core/src/main/scala/com/typesafe/tools/mima/core/BufferReader.scala#L41

@milessabin
Copy link

Is there any activity on this?

@ktoso
Copy link
Contributor

ktoso commented Jul 24, 2016

@wsargent has a WIP about it, will you have some time to push it over the finish line Will?

@JoshRosen
Copy link
Contributor

@wsargent, I don't think that nextBytes can be the cause here because I've observed this in 0.1.9 and that nextBytes method appears to be unused as of that release.

@dwijnand
Copy link
Collaborator

Also fixed by #129?

@SethTisue
Copy link
Collaborator

SethTisue commented Oct 20, 2016

yeah, please let us know, y'all, if you ever still see this after upgrading to 0.1.11, which is now published

@SethTisue SethTisue self-assigned this Oct 20, 2016
@SethTisue SethTisue added this to the 0.1.11 milestone Oct 26, 2016
@SethTisue
Copy link
Collaborator

optimistically closing, we can reopen if needed

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

No branches or pull requests

9 participants