Re: [scala-user] weird compilation issue

76 views
Skip to first unread message

Mirco Dotta

unread,
Feb 29, 2012, 2:07:59 AM2/29/12
to scala-i...@googlegroups.com
(moving this discussion to scala-ide-user)

Hi Konstantine,

That is a "funny" one, would be good to isolate it. I'll try today if I can reproduce it, 
but the crash my depend on some other file as well. Is the project you are working 
on open source? If yes, let me know where I can grab it, so that I can work on 
reducing the problem to a simpler test case. 

Two things you could try in the meanwhile:

1 - Can you compile the code using SBT alone? (you need to SBT-fy your project)
2 - In the Scala IDE, if you change switch the builder from `sbt` to `refined`, do you see any difference? (to do so, right click on the project folder, then Properties > Scala > Compiler > Builder tab)

If you don't mind, the scala-ide-user ML (https://groups.google.com/group/scala-ide-user) is a better place to 
keep discussing about this issue.


-- Mirco

On Feb 25, 2012, at 2:18 PM, Konstantine Kougios wrote:

I am getting an error msg:

The SBT builder crashed while compiling your project. This is a bug in the Scala compiler or SBT. Check the Erorr Log for details. The error message is: null

while compiling my code within eclipse. This happens when I add the following code to my class:

val runningTasks = new java.util.concurrent.ConcurrentSkipListSet[RunningTask]

If instead of using
ConcurrentSkipListSet I use HashSet, it compiles fine.

The issue occurs only when I use this code within my class (full class code follows). If I use the code in an other empty class, it compiles ok.

The error log is:

java.lang.Error
    at scala.tools.nsc.symtab.SymbolTable.abort(SymbolTable.scala:35)
    at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:737)
    at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4273)
    at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:2100)
    at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$24.apply(Typers.scala:2184)
    at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$24.apply(Typers.scala:2184)
    at scala.collection.immutable.List.loop$1(List.scala:117)
    at scala.collection.immutable.List.mapConserve(List.scala:133)
    at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2184)
    at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:1512)
    at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:1278)
    at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3912)
    at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:731)
    at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4273)
    at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:2100)
    at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$24.apply(Typers.scala:2184)
    at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$24.apply(Typers.scala:2184)
    at scala.collection.immutable.List.loop$1(List.scala:117)
    at scala.collection.immutable.List.mapConserve(List.scala:133)
    at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:2184)
    at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:3908)
    at scala.tools.nsc.transform.Erasure$Eraser.typed1(Erasure.scala:731)
    at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4273)
    at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4333)
    at scala.tools.nsc.transform.Erasure$ErasureTransformer$$anonfun$transform$1.apply(Erasure.scala:1182)
    at scala.tools.nsc.transform.Erasure$ErasureTransformer$$anonfun$transform$1.apply(Erasure.scala:1177)
    at scala.tools.nsc.symtab.SymbolTable.atPhase(SymbolTable.scala:95)
    at scala.tools.nsc.transform.Erasure$ErasureTransformer.transform(Erasure.scala:1177)
    at scala.tools.nsc.ast.Trees$Transformer.transformUnit(Trees.scala:892)
    at scala.tools.nsc.transform.Transform$Phase.apply(Transform.scala:30)
    at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:329)
    at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:297)
    at scala.tools.nsc.Global$GlobalPhase$$anonfun$run$1.apply(Global.scala:297)
    at scala.collection.Iterator$class.foreach(Iterator.scala:660)
    at scala.collection.mutable.ListBuffer$$anon$1.foreach(ListBuffer.scala:316)
    at scala.tools.nsc.Global$GlobalPhase.run(Global.scala:297)
    at scala.tools.nsc.Global$Run.compileSources(Global.scala:953)
    at scala.tools.nsc.Global$Run.compile(Global.scala:1038)
    at xsbt.CompilerInterface.run(CompilerInterface.scala:106)
    at scala.tools.eclipse.buildmanager.sbtintegration.ScalaSbtCompiler.compile(ScalaSbtCompiler.scala:35)
    at scala.tools.eclipse.buildmanager.sbtintegration.AnalysisCompile$$anonfun$8.compileScala$1(AnalysisCompile.scala:124)
    at scala.tools.eclipse.buildmanager.sbtintegration.AnalysisCompile$$anonfun$8.apply(AnalysisCompile.scala:162)
    at scala.tools.eclipse.buildmanager.sbtintegration.AnalysisCompile$$anonfun$8.apply(AnalysisCompile.scala:99)
    at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:21)
    at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:19)
    at sbt.inc.Incremental$.cycle(Incremental.scala:33)
    at sbt.inc.Incremental$.compile(Incremental.scala:20)
    at sbt.inc.IncrementalCompile$.apply(Compile.scala:17)
    at scala.tools.eclipse.buildmanager.sbtintegration.AnalysisCompile.doCompile(AnalysisCompile.scala:180)
    at scala.tools.eclipse.buildmanager.sbtintegration.EclipseSbtBuildManager.runCompiler(EclipseSbtBuildManager.scala:360)
    at scala.tools.eclipse.buildmanager.sbtintegration.EclipseSbtBuildManager.update(EclipseSbtBuildManager.scala:327)
    at scala.tools.eclipse.buildmanager.sbtintegration.EclipseSbtBuildManager.build(EclipseSbtBuildManager.scala:389)
    at scala.tools.eclipse.ScalaProject.build(ScalaProject.scala:697)
    at scala.tools.eclipse.ScalaBuilder.build(ScalaBuilder.scala:107)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:239)
    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:292)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:295)
    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:351)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:374)
    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:143)
    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:241)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)


Should I log this as a bug of the compiler and is there a workaround?

Thanks,

Kostas

P.S. my full class:









Full class code:

package com.rits.adminconsolebackend.managers
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Qualifier
import com.rits.configuration.Configuration
import java.io.File
import com.rits.adminconsolebackend.model._
import com.googlecode.concurrent.ExecutorServiceManager
import com.googlecode.scalascriptengine.ScalaScriptEngine
import com.googlecode.scalascriptengine.OnChangeRefresh
import com.googlecode.scalascriptengine.Config
import com.googlecode.scalascriptengine.RefreshSynchronously
import com.rits.logging.Logging
import com.rits.adminconsolebackend.model.Executable
import com.rits.adminconsolebackend.model.Status
import com.rits.adminconsolebackend.model.StopException
import com.googlecode.scalascriptengine.FromClasspathFirst
import java.util.concurrent.atomic.AtomicLong

/**
 * @author kostantinos.kougios
 *
 * 21 Feb 2012
 */
class TasksManager(parameters: Map[String, String]) extends Logging {
    private val runningTasks = new java.util.concurrent.ConcurrentSkipListSet[RunningTask]
    private val executor = ExecutorServiceManager.newFixedThreadPool(parameters("TasksManager.maxThreads").toInt)
    private val id = new AtomicLong

    val scriptProjects = parameters("script-projects").split(",").map(_.trim)

    private val scriptEngine = new ScalaScriptEngine(Config(
        scriptProjects.map(n => projectSrcFolder(n)).toSet,
        ScalaScriptEngine.currentClassPath,
        Set(),
        ScalaScriptEngine.tmpOutputFolder)) with OnChangeRefresh with RefreshSynchronously with FromClasspathFirst {
        override val recheckEveryMillis = 1000.toLong
    }

    def projectSrcFolder(projectFolder: String) = new File(Configuration.workspaceFolder, projectFolder + "/src/main/java")

    def list: Array[Project] = scriptProjects.map { projectFolder =>
        new Project(projectFolder) {
            val directory = Directory(this, projectSrcFolder(projectFolder))
        }
    }

    def runNow(task: Task, params: Map[String, Any]) = {

        info("starting %s".format(task.name))
        val project = task.project
        val path = project.directory.file.getAbsolutePath
        val className = task.file.getAbsolutePath.substring(path.length + 1, task.file.getAbsolutePath.length - 6).replace('/', '.')
        scriptEngine.newInstance[Any](className) match {
            case executable: Executable[_] =>
                val status = new Status(params, task.file.getParentFile)
                val runningTask = new RunningTask(id.incrementAndGet, task, status)
                //runningTasks.add(runningTask)
                executor.submit {
                    Thread.currentThread.setName(task.name)
                    val outcome = try {
                        executable.execute(status)
                    } catch {
                        case e: StopException =>
                            info("%s stopped".format(task))
                            None
                        case e =>
                            error("%s :".format(task), e)
                            None
                    }
                    info("%s is now complete, outcome : %s".format(task.name, outcome))
                }
        }
    }
}



Konstantine Kougios

unread,
Mar 7, 2012, 4:02:54 PM3/7/12
to Mirco Dotta, scala-user, scala-i...@googlegroups.com
Hi Mirco, unfortunately the project is not open source. Also I modified it quite a lot recently and the problem went away since I decided not to use a ConcurrentSkipListSet.

Regards,

Kostas

Mirco Dotta

unread,
Mar 7, 2012, 4:38:51 PM3/7/12
to scala-i...@googlegroups.com
Hi Mirco, unfortunately the project is not open source. Also I modified it quite a lot recently and the problem went away since I decided not to use a ConcurrentSkipListSet.

I see. Sorry for not getting back, I haven't forgotten you, simply been busy with other stuff ;) 

I still plan to check the code you provided to see if I can reproduce it, but this kind of issues usually require a sequence 
of steps to be reproduced. I fear that using a ConcurrentSkipListSet alone won't be enough, but I'll give it a try anyway.
Reply all
Reply to author
Forward
0 new messages