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

Fixed indexOutOfBounds bug when the last bytecode of a function has 0 size #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

onlinecco
Copy link

If a label or any bytecode with size 0 is the last bytecode of a function. There will be an index out of bounds exception at at cafebabe.CodeHandler$$anonfun$computeMaxStack$1.apply(CodeHandler.scala:156)

This is caused by the following code in CodeHandler.scala

val actualSize = abcList.map(_.size).sum
val codeArray = new Array[AbstractByteCode](actualSize)

locally {
  var pc = 0
  for(abc <- abcList) {
    codeArray(pc) = abc
    pc += abc.size
  }
}

actualSize is calculated as the sum of size of all instructions where the size of a label instruction is 0. But if a label is at the end of the bytecode list, and the value of pc will equal to the the calculated actualSize therefore caused the index out of bounds exception on the codeArray.

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

Successfully merging this pull request may close these issues.

1 participant