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

java.lang.ArrayIndexOutOfBoundsException: -1 in BackendUtils.enqInsnIndex$1 #10032

Closed
scabug opened this issue Nov 6, 2016 · 4 comments
Closed
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Nov 6, 2016

Compiler aborts with message

java.lang.ArrayIndexOutOfBoundsException: -1
	at scala.tools.nsc.backend.jvm.analysis.BackendUtils.enqInsnIndex$1(BackendUtils.scala:430)
	at scala.tools.nsc.backend.jvm.analysis.BackendUtils.enqInsn$1(BackendUtils.scala:426)
	at scala.tools.nsc.backend.jvm.analysis.BackendUtils.computeMaxLocalsMaxStack(BackendUtils.scala:477)
	at scala.tools.nsc.backend.jvm.analysis.BackendUtils$AsmAnalyzer.<init>(BackendUtils.scala:35)
	at scala.tools.nsc.backend.jvm.opt.LocalOpt.removeUnreachableCodeImpl(LocalOpt.scala:488)
	at scala.tools.nsc.backend.jvm.opt.LocalOpt.removalRound$2(LocalOpt.scala:275)
	at scala.tools.nsc.backend.jvm.opt.LocalOpt.methodOptimizations(LocalOpt.scala:354)
	at scala.tools.nsc.backend.jvm.opt.LocalOpt.$anonfun$methodOptimizations$1(LocalOpt.scala:195)
	at scala.tools.nsc.backend.jvm.opt.LocalOpt.$anonfun$methodOptimizations$1$adapted(LocalOpt.scala:194)
	at scala.collection.TraversableOnce.$anonfun$foldLeft$1(TraversableOnce.scala:157)
	at scala.collection.TraversableOnce.$anonfun$foldLeft$1$adapted(TraversableOnce.scala:157)
	at scala.collection.AbstractIterator.foreach(Iterator.scala:932)
	at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
	at scala.collection.TraversableOnce.foldLeft(TraversableOnce.scala:157)
	at scala.collection.TraversableOnce.foldLeft$(TraversableOnce.scala:155)
	at scala.collection.AbstractTraversable.foldLeft(Traversable.scala:104)
	at scala.tools.nsc.backend.jvm.opt.LocalOpt.methodOptimizations(LocalOpt.scala:194)
	at scala.tools.nsc.backend.jvm.GenBCode$BCodePhase$Worker2.$anonfun$localOptimizations$1(GenBCode.scala:248)
	at scala.tools.nsc.backend.jvm.GenBCode$BCodePhase$Worker2.localOptimizations(GenBCode.scala:248)
	at scala.tools.nsc.backend.jvm.GenBCode$BCodePhase$Worker2.run(GenBCode.scala:267)
	at scala.tools.nsc.backend.jvm.GenBCode$BCodePhase.buildAndSendToDisk(GenBCode.scala:384)
	at scala.tools.nsc.backend.jvm.GenBCode$BCodePhase.run(GenBCode.scala:350)
	at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1404)
	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1389)
	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1384)
	at scala.tools.nsc.Global$Run.compile(Global.scala:1478)
	at xsbt.CachedCompiler0.run(CompilerInterface.scala:116)

Stacktrace leads to

if (insnIndex < size && stackHeights(insnIndex) != -1)

So insnIndex is equal -1 obviously.

Mailing list
https://groups.google.com/d/msg/scala-internals/ixmajCw9nfg/kaIoa7BpAwAJ
source code repo with reproducer:
https://github.com/sgrouples/framework/tree/scala-2.12.0-wip

to reproduce- checkout and run sbt compile

@scabug
Copy link
Author

scabug commented Nov 6, 2016

Imported From: https://issues.scala-lang.org/browse/SI-10032?orig=1
Reporter: Marek Żebrowski (marekzebrowski)
Affected Versions: 2.12.0

@scabug
Copy link
Author

scabug commented Nov 7, 2016

@lrytz said:
Minimized (the source is method proc2, https://github.com/sgrouples/framework/blob/scala-2.12.0-wip/core/actor/src/main/scala/net/liftweb/actor/LiftActor.scala#L244-L335)

class C {
  def f(): Unit = {
    try {
      this.synchronized { return }
    } finally {
      this.synchronized { () }
    }
  }
}

@scabug
Copy link
Author

scabug commented Nov 7, 2016

@lrytz said (edited on Nov 7, 2016 8:45:34 PM UTC):
Example without synchronized:

  def f(): Int = {
    try {
      try { return 1 }
      finally { println() }
    } finally {
      try { println() } finally { println() }
    }
  }

@scabug
Copy link
Author

scabug commented Nov 8, 2016

@lrytz said:
scala/scala#5509

@scabug scabug closed this as completed Nov 10, 2016
@scabug scabug added this to the 2.12.1 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants