The following lincheck test deadlocks on a monitor wait, but lincheck fails to report the deadlock and rather throws an internal NPE.
import org.jetbrains.kotlinx.lincheck.annotations.Operation
import org.jetbrains.kotlinx.lincheck.check
import org.jetbrains.kotlinx.lincheck.strategy.managed.modelchecking.ModelCheckingOptions
import org.junit.jupiter.api.Test
class LinTest {
private val guard = Object()
@Operation
fun foo() {
synchronized(guard) {
guard.wait()
}
}
@Test
fun test() = ModelCheckingOptions().actorsBefore(0).check(this::class)
}
Output:
java.lang.NullPointerException
at org.jetbrains.kotlinx.lincheck.strategy.managed.MonitorTracker.releaseMonitor(ManagedStrategy.kt:867)
at org.jetbrains.kotlinx.lincheck.strategy.managed.ManagedStrategy.beforeLockRelease$lincheck(ManagedStrategy.kt:473)
at LinTest.foo(LinTest.kt:12)
at org.jetbrains.kotlinx.lincheck.runner.TestThreadExecution38.run(Unknown Source)
at org.jetbrains.kotlinx.lincheck.runner.FixedActiveThreadsExecutor$testThreadRunnable$1.run(FixedActiveThreadsExecutor.kt:173)
at java.base/java.lang.Thread.run(Thread.java:1589)
The following lincheck test deadlocks on a monitor wait, but lincheck fails to report the deadlock and rather throws an internal NPE.
Output: