scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
232 stars 21 forks source link

StackOverflow in the Eclipse plugin #3131

Closed scabug closed 13 years ago

scabug commented 14 years ago

When using the scala compiler, the following code fails properly:

object Crasher

object Test { def good(n : Int) : Unit = { }

def kaboom(n: Int) : Crasher = {

}

}

/home/chemouil/testCrash.scala:7: error: not found: type Crasher def kaboom(n: Int) : Crasher = { ^ one error found

The same code triggers a stack overflow when loaded in the Eclipse plugin.

Log:

!ENTRY ch.epfl.lamp.sdt.core 4 4 2010-03-02 11:34:16.709 !MESSAGE Failure in presentation compiler !STACK 0 java.lang.StackOverflowError at sun.nio.cs.UTF_8$$Encoder.encodeLoop(UTF_8.java:447) at java.nio.charset.CharsetEncoder.encode(CharsetEncoder.java:544) at sun.nio.cs.StreamEncoder.implWrite(StreamEncoder.java:252) at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:106) at java.io.OutputStreamWriter.write(OutputStreamWriter.java:190) at java.io.BufferedWriter.flushBuffer(BufferedWriter.java:111) at java.io.PrintStream.write(PrintStream.java:476) at java.io.PrintStream.print(PrintStream.java:619) at java.io.PrintStream.println(PrintStream.java:773) at scala.Console$$.println(Console.scala:198) at scala.tools.eclipse.ScalaPresentationCompiler$$EclipseTyperRun.compileSourceFor(ScalaPresentationCompiler.scala:142) at scala.tools.eclipse.ScalaPresentationCompiler$$EclipseTyperRun.compileSourceFor(ScalaPresentationCompiler.scala:130) at scala.tools.nsc.typechecker.Typers$$Typer.typedIdent$$1(Typers.scala:3683) at scala.tools.nsc.typechecker.Typers$$Typer.typedIdent$$1(Typers.scala:3684) at scala.tools.nsc.typechecker.Typers$$Typer.typedIdent$$1(Typers.scala:3684) at scala.tools.nsc.typechecker.Typers$$Typer.typedIdent$$1(Typers.scala:3684) at scala.tools.nsc.typechecker.Typers$$Typer.typedIdent$$1(Typers.scala:3684) at scala.tools.nsc.typechecker.Typers$$Typer.typedIdent$$1(Typers.scala:3684) at scala.tools.nsc.typechecker.Typers$$Typer.typedIdent$$1(Typers.scala:3684) [ad vitam eternam]

Then Eclipse dies.

scabug commented 14 years ago

Imported From: https://issues.scala-lang.org/browse/SI-3131?orig=1 Reporter: Simon Chemouil (magnet)

scabug commented 14 years ago

@milessabin said: Works for me ... how do you have your Eclipse heap and stack configured?

Also, what version? I can tell from the stack trace that it's a recent nightly, but I would be helpful to know exactly.

scabug commented 14 years ago

Simon Chemouil (magnet) said: Sometimes it does work, and after a few saves (or adding a method above) it triggers the StackOverflowError.

Try with:

object Crasher

object Test {

def good2(n: Int) : Boolean = { }

def good(n : Int) : Unit = { }

def kaboom(n: Int) : Crasher = {

}

}

(two errors, triggers crash). Maybe it has been fixed in a recent nightly, I have avoided updates these days because of the release of Eclipse 3.5.2 (overcrowded servers and very bad time to break my Eclipse install).

I had the problem with two different installs.

Version: Scala Eclipse Plugin 2.8.0.r20879-b20100214035850 ch.epfl.lamp.sdt.feature.group

eclipse.ini: --launcher.library plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.0.200.v20090519 -startup plugins/org.eclipse.equinox.launcher_1.0.201.R35x_v20090715.jar -product org.eclipse.epp.package.rcp.product -showsplash org.eclipse.platform --launcher.XXMaxPermSize 256m -showsplash org.eclipse.platform --launcher.XXMaxPermSize 256m -showsplash org.eclipse.platform --launcher.XXMaxPermSize 256m -vmargs -Dosgi.requiredJavaVersion=1.5 -XX:MaxPermSize=256m -Xms40m -Xmx512m

Tell me if you need anything else.

scabug commented 14 years ago

@milessabin said: I don't see a -Xss value there, which means that you're using the default for your JVM. That's almost certainly borderline for the Scala IDE (which explains why you see the problem intermittently) and quite possibly for any Eclipse application.

The recommended heap configuration can be found [http://www.scala-lang.org/node/94 here]. If you don't have sufficient physical memory to follow that to the letter, allocate as much as you're able, and in particular specify -Xss1M.

scabug commented 14 years ago

Paul LaCrosse (pjlacrosse) said: I have the heap config as recommended, and I get stack overflow errors, too.

I don't have a small reproducible case, unfortunately, as it happens while working on a medium size project, triggered by code in the editor that is flagged as incorrect during active coding. Changing the code so that it is correct does not make the issue disappear, as once it happens, I have to close Eclipse to make it stop.

scabug commented 14 years ago

@milessabin said: @pjlacrosse what Scala IDE version?

Please bear in mind that a stack overflow can just be ... a stack overflow. During typechecking the stack depth will grow depending on the complexity of your application and the right first response is to attempt to increase the stack size until the problem goes away.

If the problem doesn't go away no matter how much you increase the stack size it could be that you've found a bug, in which case a small, self-contained, reproducing example is extremely helpful.