scala-ide / scala-search

Next Scala Search Engine
6 stars 10 forks source link

Workaround for race condition in symbol importer #73

Closed dotta closed 11 years ago

dotta commented 11 years ago

Looks like the symbol importer module isn't thread-safe. In particular, before importing a symbol from one presentation compiler to another, we need to make sure the symbol's owner chain, and all companion's symbols are fully initialized.

Fixes #1001826

mads-hartmann commented 11 years ago

@dotta Looks good to me. We might want to consider @ignore'ing the test deletesIndexWhenProjectIsDeleted till I find a way to make it stable :)

dotta commented 11 years ago

@mads379 Thanks for chiming in :)

The thing that worries me is this exception (obtained from the log of the failing build)

013-09-02 15:42:21,882  INFO [Worker-2] - ScalaProject - setting additional parameters: 
2013-09-02 15:42:21,964  INFO [Worker-2] - ScalaProject - Throwable when intializing presentation compiler!!! class Object does not have a member getClass
scala.reflect.internal.FatalError: class Object does not have a member getClass
    at scala.reflect.internal.Definitions$DefinitionsClass.scala$reflect$internal$Definitions$DefinitionsClass$$fatalMissingSymbol(Definitions.scala:1068)
    at scala.reflect.internal.Definitions$DefinitionsClass.getMember(Definitions.scala:1085)
    at scala.reflect.internal.Definitions$DefinitionsClass.getMemberMethod(Definitions.scala:1119)
    at scala.reflect.internal.Definitions$DefinitionsClass.Any_getClass$lzycompute(Definitions.scala:838)
    at scala.reflect.internal.Definitions$DefinitionsClass.Any_getClass(Definitions.scala:838)
    at scala.reflect.internal.Definitions$DefinitionsClass.syntheticCoreMethods$lzycompute(Definitions.scala:1196)
    at scala.reflect.internal.Definitions$DefinitionsClass.syntheticCoreMethods(Definitions.scala:1190)
    at scala.reflect.internal.Definitions$DefinitionsClass.symbolsNotPresentInBytecode$lzycompute(Definitions.scala:1220)
    at scala.reflect.internal.Definitions$DefinitionsClass.symbolsNotPresentInBytecode(Definitions.scala:1220)
    at scala.reflect.internal.Definitions$DefinitionsClass.init(Definitions.scala:1272)
    at scala.tools.nsc.Global$Run.<init>(Global.scala:1225)
    at scala.tools.nsc.interactive.Global$TyperRun.<init>(Global.scala:1177)
    at scala.tools.nsc.interactive.Global.newTyperRun(Global.scala:1200)
    at scala.tools.nsc.interactive.Global.<init>(Global.scala:281)
    at scala.tools.eclipse.ScalaPresentationCompiler.<init>(ScalaPresentationCompiler.scala:52)
    at scala.tools.eclipse.ScalaProject$$anon$1.create(ScalaProject.scala:118)
    at scala.tools.eclipse.ScalaProject$$anon$1.create(ScalaProject.scala:113)
    at scala.tools.eclipse.util.Cached$class.apply(Cached.scala:30)
    at scala.tools.eclipse.ScalaProject$$anon$1.apply(ScalaProject.scala:113)
    at scala.tools.eclipse.ScalaProject.withPresentationCompiler(ScalaProject.scala:607)
    at scala.tools.eclipse.ScalaProject.withSourceFile(ScalaProject.scala:616)
    at scala.tools.eclipse.InteractiveCompilationUnit$class.withSourceFile(InteractiveCompilationUnit.scala:66)
    at scala.tools.eclipse.javaelements.ScalaSourceFile.withSourceFile(ScalaSourceFile.scala:76)
    at org.scala.tools.eclipse.search.indexing.OccurrenceCollector$.findOccurrences(OccurrenceCollector.scala:42)
    at org.scala.tools.eclipse.search.indexing.SourceIndexer$$anonfun$indexScalaFile$2.apply(SourceIndexer.scala:116)
    at org.scala.tools.eclipse.search.indexing.SourceIndexer$$anonfun$indexScalaFile$2.apply(SourceIndexer.scala:115)
    at scala.util.Success.flatMap(Try.scala:201)
    at org.scala.tools.eclipse.search.indexing.SourceIndexer.indexScalaFile(SourceIndexer.scala:115)
    at org.scala.tools.eclipse.search.indexing.SourceIndexer$$anonfun$indexIFile$2.apply(SourceIndexer.scala:87)
    at org.scala.tools.eclipse.search.indexing.SourceIndexer$$anonfun$indexIFile$2.apply(SourceIndexer.scala:87)
    at scala.Option.fold(Option.scala:157)
    at org.scala.tools.eclipse.search.indexing.SourceIndexer.indexIFile(SourceIndexer.scala:86)
    at org.scala.tools.eclipse.search.jobs.ProjectIndexJob.run(ProjectIndexJob.scala:101)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)

Will have a deeper look at it tomorrow, but I don't think I've ever seen it.

dotta commented 11 years ago

PLS REBUILD/scala-search-master-2.11-pr-validator@75b7bcc

scala-jenkins commented 11 years ago

(kitty-note-to-self: ignore 23773092) :cat: Roger! Rebuilding scala-search-master-2.11-pr-validator for 75b7bcce. :rotating_light:

dotta commented 11 years ago

@dragos This seems to work, are you ok with merging it?

dragos commented 11 years ago

LGTM