jlleitschuh
12/07/2018, 5:57 PMLazyScriptDefinitionProvider
.octylFractal
12/07/2018, 6:04 PMoctylFractal
12/07/2018, 6:08 PMTakeSequence
https://github.com/JetBrains/kotlin/blob/master/libraries/stdlib/src/kotlin/collections/Sequences.kt#L350jlleitschuh
12/07/2018, 6:09 PMilya.gorbunov
12/07/2018, 6:15 PMSequence
is usually safe in a sense that you can call iterator()
function concurrently on it. The returned Iterator
object however often contains a mutable state that is not synchronized and therefore is not thread safe.jlleitschuh
12/07/2018, 6:17 PMoverride fun findScriptDefinition(fileName: String): KotlinScriptDefinition? =
if (nonScriptFileName(fileName)) null
else lock.read {
cachedDefinitions.firstOrNull { it.isScript(fileName) }
}
I don't think this is accurate.
I think this is why we're getting the rare exception.
I think this is never hit by the normal compiler operation (non-script compilation) because the logic short circuits.
if (nonScriptFileName(fileName)) null
ilya.gorbunov
12/07/2018, 6:20 PMCachingSequence
is used there and it uses synchronization in its iterator. However that iterator can call underlying iterator's hasNext
concurrently under read lock and that's not safe. cc @ilya.chernikovjlleitschuh
12/07/2018, 6:22 PMjlleitschuh
12/10/2018, 2:44 PMilya.chernikov
12/10/2018, 3:05 PMjlleitschuh
12/10/2018, 3:09 PMilya.chernikov
12/10/2018, 3:12 PMilya.chernikov
12/13/2018, 9:16 AMjlleitschuh
12/13/2018, 1:30 PM