summaryrefslogtreecommitdiff
path: root/src/interactive
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2014-02-07 16:40:44 +0100
committerJason Zaugg <jzaugg@gmail.com>2014-02-10 17:20:48 +0100
commit894aee1347600201dd2decbd07bcf7820cbbee3d (patch)
tree22ba01dd5b4c319cc04899dac873f8664a28fa18 /src/interactive
parentea36cada85e77b7dde85db62ddb4a6da88f76eb4 (diff)
downloadscala-894aee1347600201dd2decbd07bcf7820cbbee3d.tar.gz
scala-894aee1347600201dd2decbd07bcf7820cbbee3d.tar.bz2
scala-894aee1347600201dd2decbd07bcf7820cbbee3d.zip
Start the PC thread only after initialization of required symbols.
If the class path is incomplete, the presentation compiler might crash during construction. If the PC thread was already started, it will never get the chance to shutdown, and the thread leaks. In the IDE, where the PC is started when needed, this can lead to a very quick depletion of JVM threads. See Scala IDE #1002016.
Diffstat (limited to 'src/interactive')
-rw-r--r--src/interactive/scala/tools/nsc/interactive/Global.scala15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/interactive/scala/tools/nsc/interactive/Global.scala b/src/interactive/scala/tools/nsc/interactive/Global.scala
index 0e897d6492..e5eeb25ddf 100644
--- a/src/interactive/scala/tools/nsc/interactive/Global.scala
+++ b/src/interactive/scala/tools/nsc/interactive/Global.scala
@@ -534,7 +534,6 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
threadId += 1
compileRunner = new PresentationCompilerThread(this, projectName)
compileRunner.setDaemon(true)
- compileRunner.start()
compileRunner
}
@@ -1252,11 +1251,21 @@ class Global(settings: Settings, _reporter: Reporter, projectName: String = "")
forceSymbolsUsedByParser()
+ /** Start the compiler background thread and turn on thread confinement checks */
+ private def finishInitialization(): Unit = {
+ // this flag turns on `assertCorrectThread checks`
+ initializing = false
+
+ // Only start the thread if initialization was successful. A crash while forcing symbols (for example
+ // if the Scala library is not on the classpath) can leave running threads behind. See Scala IDE #1002016
+ compileRunner.start()
+ }
+
/** The compiler has been initialized. Constructors are evaluated in textual order,
- * so this is set to true only after all super constructors and the primary constructor
+ * if we reached here, all super constructors and the primary constructor
* have been executed.
*/
- initializing = false
+ finishInitialization()
}
object CancelException extends Exception