diff options
author | Iulian Dragos <jaguarul@gmail.com> | 2014-02-07 16:40:44 +0100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2014-02-10 17:20:48 +0100 |
commit | 894aee1347600201dd2decbd07bcf7820cbbee3d (patch) | |
tree | 22ba01dd5b4c319cc04899dac873f8664a28fa18 /src | |
parent | ea36cada85e77b7dde85db62ddb4a6da88f76eb4 (diff) | |
download | scala-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')
-rw-r--r-- | src/interactive/scala/tools/nsc/interactive/Global.scala | 15 |
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 |