Skip to content

Commit fca1fd4

Browse files
qwwdfsadpablobaxter
authored andcommitted
Make helpRemove actually lock-free and address multiple chained removed nodes (Kotlin#2795)
* The previous version invoked correctPrev on the next node and bailed out fi it was removed, effectively blocking the progress of any attempts to remove previous node * Use helpRemovePrev in helpRemove that was actually implemented to avoid such problem Fixes Kotlin#2590
1 parent 00087a5 commit fca1fd4

File tree

3 files changed

+2
-7
lines changed

3 files changed

+2
-7
lines changed

kotlinx-coroutines-core/jvm/src/internal/LockFreeLinkedList.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public actual open class LockFreeLinkedListNode {
259259
// Helps with removal of this node
260260
public actual fun helpRemove() {
261261
// Note: this node must be already removed
262-
(next as Removed).ref.correctPrev(null)
262+
(next as Removed).ref.helpRemovePrev()
263263
}
264264

265265
// Helps with removal of nodes that are previous to this

kotlinx-coroutines-core/jvm/test/AbstractLincheckTest.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ abstract class AbstractLincheckTest : VerifierState() {
1515
open fun StressOptions.customize(isStressTest: Boolean): StressOptions = this
1616

1717
@Test
18-
open fun modelCheckingTest() = ModelCheckingOptions()
18+
fun modelCheckingTest() = ModelCheckingOptions()
1919
.iterations(if (isStressTest) 100 else 20)
2020
.invocationsPerIteration(if (isStressTest) 10_000 else 1_000)
2121
.commonConfiguration()

kotlinx-coroutines-core/jvm/test/lincheck/MutexLincheckTest.kt

-5
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,10 @@ import kotlinx.coroutines.sync.*
99
import org.jetbrains.kotlinx.lincheck.*
1010
import org.jetbrains.kotlinx.lincheck.annotations.Operation
1111
import org.jetbrains.kotlinx.lincheck.strategy.managed.modelchecking.*
12-
import org.junit.*
1312

1413
class MutexLincheckTest : AbstractLincheckTest() {
1514
private val mutex = Mutex()
1615

17-
override fun modelCheckingTest() {
18-
// Ignored via empty body as the only way
19-
}
20-
2116
@Operation
2217
fun tryLock() = mutex.tryLock()
2318

0 commit comments

Comments
 (0)