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

Mismatch in stack heights #8330

Closed
scabug opened this issue Feb 23, 2014 · 8 comments
Closed

Mismatch in stack heights #8330

scabug opened this issue Feb 23, 2014 · 8 comments

Comments

@scabug
Copy link

scabug commented Feb 23, 2014

This used to compile in 2.10.3:

class A {
  def f: Boolean = {
  	try {
      val x = 12
      ()
	} catch {
		case ex: Exception => null
	}
    true
  }
}

but doesn't with current master:

RUNNER=scalac scala-hash scala/master ../OptimizerCrash.scala
RUNNER=scalac scala-hash scala/master ../OptimizerCrash.scala
error: java.lang.ArrayIndexOutOfBoundsException: 0
	at scala.tools.asm.Frame.merge(Frame.java:1397)
	at scala.tools.asm.Frame.merge(Frame.java:1374)
	at scala.tools.asm.MethodWriter.visitMaxs(MethodWriter.java:1303)
	at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder.genMethod(GenASM.scala:1450)
	at scala.tools.nsc.backend.jvm.GenASM$JPlainBuilder.genClass(GenASM.scala:1279)
	at scala.tools.nsc.backend.jvm.GenASM$AsmPhase.emitFor$1(GenASM.scala:135)
	at scala.tools.nsc.backend.jvm.GenASM$AsmPhase.run(GenASM.scala:141)

We regressed in 9506d5273b4b10037c202f01e8556076998bd064.

@scabug
Copy link
Author

scabug commented Feb 23, 2014

@scabug
Copy link
Author

scabug commented Feb 23, 2014

@magarciaEPFL said:
Just checked, the new backend http://magarciaepfl.github.io/scala/ isn't prone to this bug.

@scabug
Copy link
Author

scabug commented Feb 23, 2014

@gkossakowski said (edited on Feb 23, 2014 10:30:12 PM UTC):
Miguel, the old wasn't either until we regressed in 9506d5273b4b10037c202f01e8556076998bd064 2 weeks ago.

Do you keep the new backend up-to-date with master?

@scabug
Copy link
Author

scabug commented Feb 23, 2014

@magarciaEPFL said:
The new backend is updated twice a week, as of this writing it's based on master as of four days ago. The webpage http://magarciaepfl.github.io/scala/ gets updated accordingly to announce what that "latest branch" is.

It would help if Jira had separate components for old and new (bytecode emitter, optimizer) as a better means to track those bugs, rather than me pasting notes-to-self of the form "the new backend doesn't exhibit this bug".

@scabug
Copy link
Author

scabug commented Feb 23, 2014

@retronym said:
"Notes to self" are better expressed as pull requests with test cases!

@scabug
Copy link
Author

scabug commented Feb 24, 2014

@gkossakowski said:
I updated the test case. Something a lot smaller is only needed to trigger this bug:

class A {
  def f: Boolean = {
  	try {
      val x = 12
      ()
	} catch {
		case ex: Exception => null
	}
    true
  }
}

@scabug
Copy link
Author

scabug commented Feb 24, 2014

@gkossakowski said:
Minimized even more:

object A {
  def f(b: Boolean): Boolean = {
  	if (b) {
      val x = 12
      ()
	} else null
    true
  }
  def main(args: Array[String]): Unit = f(true)
}

results in VerifyError:

java.lang.VerifyError: (class: A$, method: f signature: (Z)Z) Inconsistent stack height 1 != 0
	at A.main(t8330.scala)

The fix is coming shortly.

@scabug
Copy link
Author

scabug commented Feb 24, 2014

@gkossakowski said:
scala/scala#3580

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