diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2014-01-15 21:07:15 +0300 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2014-01-21 14:12:39 +0300 |
commit | 2bd304404ac00939a18a678aa982da9cbb3471a2 (patch) | |
tree | 3cbd2f12522953a0cd9945aca7fae02f44ec1b94 /src/reflect/scala/reflect/internal/Importers.scala | |
parent | f142d854d3401728546ae6822662b7a3ad655a58 (diff) | |
download | scala-2bd304404ac00939a18a678aa982da9cbb3471a2.tar.gz scala-2bd304404ac00939a18a678aa982da9cbb3471a2.tar.bz2 scala-2bd304404ac00939a18a678aa982da9cbb3471a2.zip |
SI-8131 fixes residual race condition in runtime reflection
Apparently some completers can call setInfo while they’re not yet done,
which resets the LOCKED flag, and makes anything that uses LOCKED to
track completion unreliable. Unfortunately, that’s exactly the mechanism
that was used by runtime reflection to elide locking for symbols that are
known to be initialized.
This commit fixes the problematic lock elision strategy by introducing
an explicit communication channel between SynchronizedSymbol’s and their
completers. Now instead of trying hard to infer whether it’s already
initialized or not, every symbol gets a volatile field that can be queried
to provide necessary information.
Diffstat (limited to 'src/reflect/scala/reflect/internal/Importers.scala')
-rw-r--r-- | src/reflect/scala/reflect/internal/Importers.scala | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/reflect/scala/reflect/internal/Importers.scala b/src/reflect/scala/reflect/internal/Importers.scala index 91ba552012..cda3e28e08 100644 --- a/src/reflect/scala/reflect/internal/Importers.scala +++ b/src/reflect/scala/reflect/internal/Importers.scala @@ -4,6 +4,7 @@ package internal import scala.collection.mutable.WeakHashMap import scala.ref.WeakReference +import scala.reflect.internal.Flags._ // SI-6241: move importers to a mirror trait Importers extends api.Importers { to: SymbolTable => @@ -87,6 +88,7 @@ trait Importers extends api.Importers { to: SymbolTable => } my setInfo GenPolyType(mytypeParams, importType(theirCore)) my setAnnotations (their.annotations map importAnnotationInfo) + markAllCompleted(my) } } } finally { @@ -142,6 +144,7 @@ trait Importers extends api.Importers { to: SymbolTable => myowner.newTypeSymbol(myname.toTypeName, mypos, myflags) } symMap.weakUpdate(their, my) + markFlagsCompleted(my)(mask = AllFlags) my setInfo recreatedSymbolCompleter(my, their) } |