The complete output with the detailed stack trace is in the file output.log
Exception stacktrace:
java.lang.IllegalStateException: Trying to switch the execution to thread 2,
but only the following threads are eligible to switch: [0]
at org.jetbrains.kotlinx.lincheck.strategy.managed.modelchecking.ModelCheckingStrategy.chooseThread(ModelCheckingStrategy.kt:306)
at org.jetbrains.kotlinx.lincheck.strategy.managed.ManagedStrategy.doSwitchCurrentThread(ManagedStrategy.kt:524)
at org.jetbrains.kotlinx.lincheck.strategy.managed.ManagedStrategy.switchCurrentThread(ManagedStrategy.kt:500)
at org.jetbrains.kotlinx.lincheck.strategy.managed.ManagedStrategy.switchCurrentThread$default(ManagedStrategy.kt:493)
at org.jetbrains.kotlinx.lincheck.strategy.managed.ManagedStrategy.newSwitchPoint(ManagedStrategy.kt:402)
at org.jetbrains.kotlinx.lincheck.strategy.managed.ManagedStrategy.newSwitchPointOnAtomicMethodCall(ManagedStrategy.kt:964)
at org.jetbrains.kotlinx.lincheck.strategy.managed.ManagedStrategy.beforeMethodCall(ManagedStrategy.kt:903)
at sun.nio.ch.lincheck.Injections.beforeMethodCall(Injections.java:249)
at kotlinx.coroutines.CancellableContinuationImpl.tryResume(CancellableContinuationImpl.kt:279)
at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:468)
at kotlinx.coroutines.CancellableContinuationImpl.completeResume(CancellableContinuationImpl.kt:591)
at com.deshyt.buffered.BufferedChannel.tryResumeRequest(BufferedChannel.kt:249)
at com.deshyt.buffered.BufferedChannel.tryResumeRequest(BufferedChannel.kt:238)
at com.deshyt.buffered.BufferedChannel.updateCellOnSend(BufferedChannel.kt:106)
at com.deshyt.buffered.BufferedChannel.send(BufferedChannel.kt:74)
at com.deshyt.ChannelTestBase.send(ChannelTestBase.kt:22)
at org.jetbrains.kotlinx.lincheck.runner.TestThreadExecution77.run(Unknown Source)
at org.jetbrains.kotlinx.lincheck.runner.FixedActiveThreadsExecutor.testThreadRunnable$lambda$10(FixedActiveThreadsExecutor.kt:172)
at java.base/java.lang.Thread.run(Thread.java:1583)
== Reporting the second execution ==
= Validation function validate has failed =
| ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| Thread 1 | Thread 2 | Thread 3 |
| ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| receive(): IndexOutOfBoundsException #1 | send(3): void | receive(): 3 |
| send(1) + cancel: IndexOutOfBoundsException #2 | receive(): IndexOutOfBoundsException #4 | receive() + cancel: IndexOutOfBoundsException #6 |
| receive(): IndexOutOfBoundsException #3 | receive() + cancel: IndexOutOfBoundsException #5 | send(1): IndexOutOfBoundsException #7 |
| ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| validate(): IndexOutOfBoundsException | | |
| ---------------------------------------------------------------------------------------------------------------------------------------------------- |
---
The number next to an exception name helps you find its stack trace provided after the interleaving section
---
java.lang.IndexOutOfBoundsException: Index 10 out of bounds for length 7
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
at java.base/java.util.Objects.checkIndex(Objects.java:385)
at java.base/java.util.ArrayList.get(ArrayList.java:427)
at org.jetbrains.kotlinx.lincheck.strategy.managed.ReplayModeLoopDetectorHelper.getCurrentHistoryNode(LoopDetector.kt:645)
at org.jetbrains.kotlinx.lincheck.strategy.managed.ReplayModeLoopDetectorHelper.getCurrentlyInSpinCycle(LoopDetector.kt:651)
at org.jetbrains.kotlinx.lincheck.strategy.managed.LoopDetector.getReplayModeCurrentlyInSpinCycle(LoopDetector.kt:120)
at org.jetbrains.kotlinx.lincheck.strategy.managed.ManagedStrategy$TraceCollector.checkActiveLockDetected(ManagedStrategy.kt:1392)
at org.jetbrains.kotlinx.lincheck.strategy.managed.ManagedStrategy.beforeMethodCall(ManagedStrategy.kt:899)
at sun.nio.ch.lincheck.Injections.beforeMethodCall(Injections.java:249)
at com.deshyt.ChannelTestBase.validate(ChannelTestBase.kt:54)
at org.jetbrains.kotlinx.lincheck.runner.TestThreadExecution83.run(Unknown Source)
at org.jetbrains.kotlinx.lincheck.runner.FixedActiveThreadsExecutor.testThreadRunnable$lambda$10(FixedActiveThreadsExecutor.kt:172)
at java.base/java.lang.Thread.run(Thread.java:1583)
The following interleaving leads to the error:
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Thread 1 | Thread 2 | Thread 3 |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| | | receive(): 3 |
| | | c.receive(): COROUTINE_SUSPENDED at ChannelTestBase.receive(ChannelTestBase.kt:29) |
| | | receiveSegment.READ: ChannelSegment#1 at BufferedChannel.receive(BufferedChannel.kt:124) |
| | | receiversCounter.getAndIncrement(): 0 at BufferedChannel.receive(BufferedChannel.kt:128) |
| | | updateCellOnReceive(0,ChannelSegment#1,0,<cont>): COROUTINE_SUSPENDED at BufferedChannel.receive(BufferedChannel.kt:144) |
| | | ChannelSegment#1.getState$kotlin_channels(0): null at BufferedChannel.updateCellOnReceive(BufferedChannel.kt:158) |
| | | sendersCounter.READ: 0 at BufferedChannel.updateCellOnReceive(BufferedChannel.kt:159) |
| | | trySuspendRequest(ChannelSegment#1,0,false,<cont>): COROUTINE_SUSPENDED at BufferedChannel.updateCellOnReceive(BufferedChannel.kt:163) |
| | | <cont>.initCancellability() at BufferedChannel.trySuspendRequest(BufferedChannel.kt:575) |
| | | <cont>.invokeOnCancellation(trySuspendRequest$2$1) at BufferedChannel.trySuspendRequest(BufferedChannel.kt:221) |
| | | ChannelSegment#1.casState$kotlin_channels(0,null,Coroutine#1): true at BufferedChannel.trySuspendRequest(BufferedChannel.kt:224) |
| | | BufferedChannel.access$expandBuffer(BufferedChannel#1) at BufferedChannel.trySuspendRequest(BufferedChannel.kt:230) |
| | | <cont>.getResult(): COROUTINE_SUSPENDED at BufferedChannel.trySuspendRequest(BufferedChannel.kt:577) |
| | | trySuspend(): true at CancellableContinuationImpl.getResult(CancellableContinuationImpl.kt:294) |
| | | getParentHandle(): ChildContinuation#1 at CancellableContinuationImpl.getResult(CancellableContinuationImpl.kt:304) |
| | | switch (reason: coroutine is suspended) |
| | | result: 3 |
| receive(): IndexOutOfBoundsException #1 | | |
| c.receive() at ChannelTestBase.receive(ChannelTestBase.kt:29) | | |
| receiveSegment.READ: ChannelSegment#1 at BufferedChannel.receive(BufferedChannel.kt:124) | | |
| receiversCounter.getAndIncrement(): 1 at BufferedChannel.receive(BufferedChannel.kt:128) | | |
| updateCellOnReceive(1,ChannelSegment#1,1,<cont>): threw IndexOutOfBoundsException at BufferedChannel.receive(BufferedChannel.kt:144) | | |
| ChannelSegment#1.getState$kotlin_channels(1): null at BufferedChannel.updateCellOnReceive(BufferedChannel.kt:158) | | |
| sendersCounter.READ: 0 at BufferedChannel.updateCellOnReceive(BufferedChannel.kt:159) | | |
| trySuspendRequest(ChannelSegment#1,1,false,<cont>): threw IndexOutOfBoundsException at BufferedChannel.updateCellOnReceive(BufferedChannel.kt:163) | | |
| <cont>.initCancellability() at BufferedChannel.trySuspendRequest(BufferedChannel.kt:575) | | |
| <cont>.invokeOnCancellation(trySuspendRequest$2$1) at BufferedChannel.trySuspendRequest(BufferedChannel.kt:221) | | |
| ChannelSegment#1.casState$kotlin_channels(1,null,Coroutine#2): true at BufferedChannel.trySuspendRequest(BufferedChannel.kt:224) | | |
| BufferedChannel.access$expandBuffer(BufferedChannel#1): threw IndexOutOfBoundsException at BufferedChannel.trySuspendRequest(BufferedChannel.kt:230) | | |
| Buffered1ChannelTest#1.c.expandBuffer(): threw IndexOutOfBoundsException at BufferedChannel.access$expandBuffer(BufferedChannel.kt:12) | | |
| bufferEndSegment.READ: ChannelSegment#1 at BufferedChannel.expandBuffer(BufferedChannel.kt:363) | | |
| bufferEnd.getAndIncrement(): 2 at BufferedChannel.expandBuffer(BufferedChannel.kt:368) | | |
| switch | | |
| | send(3) | |
| | receive(): IndexOutOfBoundsException #4 | |
| | c.receive() at ChannelTestBase.receive(ChannelTestBase.kt:29) | |
| | receiveSegment.READ: ChannelSegment#1 at BufferedChannel.receive(BufferedChannel.kt:124) | |
| | receiversCounter.getAndIncrement(): 2 at BufferedChannel.receive(BufferedChannel.kt:128) | |
| | findSegmentReceive(1,ChannelSegment#1): ChannelSegment#2 at BufferedChannel.receive(BufferedChannel.kt:136) | |
| | updateCellOnReceive(2,ChannelSegment#2,0,<cont>): threw IndexOutOfBoundsException at BufferedChannel.receive(BufferedChannel.kt:144) | |
| | ChannelSegment#2.getState$kotlin_channels(0): null at BufferedChannel.updateCellOnReceive(BufferedChannel.kt:158) | |
| | sendersCounter.READ: 1 at BufferedChannel.updateCellOnReceive(BufferedChannel.kt:159) | |
| | trySuspendRequest(ChannelSegment#2,0,false,<cont>): threw IndexOutOfBoundsException at BufferedChannel.updateCellOnReceive(BufferedChannel.kt:163) | |
| | <cont>.initCancellability() at BufferedChannel.trySuspendRequest(BufferedChannel.kt:575) | |
| | <cont>.invokeOnCancellation(trySuspendRequest$2$1) at BufferedChannel.trySuspendRequest(BufferedChannel.kt:221) | |
| | ChannelSegment#2.casState$kotlin_channels(0,null,Coroutine#3): true at BufferedChannel.trySuspendRequest(BufferedChannel.kt:224) | |
| | BufferedChannel.access$expandBuffer(BufferedChannel#1) at BufferedChannel.trySuspendRequest(BufferedChannel.kt:230) | |
| | Buffered1ChannelTest#1.c.expandBuffer() at BufferedChannel.access$expandBuffer(BufferedChannel.kt:12) | |
| | bufferEndSegment.READ: ChannelSegment#1 at BufferedChannel.expandBuffer(BufferedChannel.kt:363) | |
| | bufferEnd.getAndIncrement(): 3 at BufferedChannel.expandBuffer(BufferedChannel.kt:368) | |
| | sendersCounter.READ: 1 at BufferedChannel.expandBuffer(BufferedChannel.kt:373) | |
| | switch | |
| | | receive() + cancel: IndexOutOfBoundsException #6 |
| | | c.receive(): COROUTINE_SUSPENDED at ChannelTestBase.receive(ChannelTestBase.kt:29) |
| | | receiveSegment.READ: ChannelSegment#2 at BufferedChannel.receive(BufferedChannel.kt:124) |
| | | receiversCounter.getAndIncrement(): 3 at BufferedChannel.receive(BufferedChannel.kt:128) |
| | | updateCellOnReceive(3,ChannelSegment#2,1,<cont>): COROUTINE_SUSPENDED at BufferedChannel.receive(BufferedChannel.kt:144) |
| | | ChannelSegment#2.getState$kotlin_channels(1): null at BufferedChannel.updateCellOnReceive(BufferedChannel.kt:158) |
| | | sendersCounter.READ: 1 at BufferedChannel.updateCellOnReceive(BufferedChannel.kt:159) |
| | | switch |
| | BufferedChannel.incCompletedExpandBufferAttempts$default(BufferedChannel#1,0,1,null) at BufferedChannel.expandBuffer(BufferedChannel.kt:376) | |
| | switch | |
| | result: IndexOutOfBoundsException #4 | |
| | receive() + cancel: IndexOutOfBoundsException #5 | |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| send(1) + cancel: IndexOutOfBoundsException #2 | | |
| receive(): IndexOutOfBoundsException #3 | | |
| validate(): IndexOutOfBoundsException | | |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Exception stack traces:
#1: java.lang.IndexOutOfBoundsException: Index 7 out of bounds for length 7
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
at java.base/java.util.Objects.checkIndex(Objects.java:385)
at java.base/java.util.ArrayList.get(ArrayList.java:427)
#2: java.lang.IndexOutOfBoundsException: Index 7 out of bounds for length 7
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
at java.base/java.util.Objects.checkIndex(Objects.java:385)
at java.base/java.util.ArrayList.get(ArrayList.java:427)
#3: java.lang.IndexOutOfBoundsException: Index 7 out of bounds for length 7
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
at java.base/java.util.Objects.checkIndex(Objects.java:385)
at java.base/java.util.ArrayList.get(ArrayList.java:427)
#4: java.lang.IndexOutOfBoundsException: Index 8 out of bounds for length 7
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
at java.base/java.util.Objects.checkIndex(Objects.java:385)
at java.base/java.util.ArrayList.get(ArrayList.java:427)
#5: java.lang.IndexOutOfBoundsException: Index 8 out of bounds for length 7
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
at java.base/java.util.Objects.checkIndex(Objects.java:385)
at java.base/java.util.ArrayList.get(ArrayList.java:427)
#6: java.lang.IndexOutOfBoundsException: Index 9 out of bounds for length 7
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
at java.base/java.util.Objects.checkIndex(Objects.java:385)
at java.base/java.util.ArrayList.get(ArrayList.java:427)
#7: java.lang.IndexOutOfBoundsException: Index 9 out of bounds for length 7
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:100)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302)
at java.base/java.util.Objects.checkIndex(Objects.java:385)
at java.base/java.util.ArrayList.get(ArrayList.java:427)
at org.jetbrains.kotlinx.lincheck.strategy.managed.ManagedStrategy.tryCollectTrace(ManagedStrategy.kt:263)
at org.jetbrains.kotlinx.lincheck.strategy.StrategyKt.verify(Strategy.kt:127)
at org.jetbrains.kotlinx.lincheck.strategy.StrategyKt.runIteration(Strategy.kt:108)
at org.jetbrains.kotlinx.lincheck.LinChecker.run(LinChecker.kt:147)
at org.jetbrains.kotlinx.lincheck.LinChecker.checkImpl(LinChecker.kt:104)
at org.jetbrains.kotlinx.lincheck.LinChecker.checkImpl$lincheck(LinChecker.kt:65)
at org.jetbrains.kotlinx.lincheck.LinChecker.check(LinChecker.kt:47)
at org.jetbrains.kotlinx.lincheck.LinChecker$Companion.check(LinChecker.kt:195)
at org.jetbrains.kotlinx.lincheck.LinCheckerKt.check(LinChecker.kt:295)
at org.jetbrains.kotlinx.lincheck.LinCheckerKt.check(LinChecker.kt:304)
at com.deshyt.TestBase.modelCheckingTest(Unknown Source)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:112)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:40)
at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:60)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:52)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
at jdk.proxy1/jdk.proxy1.$Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker$2.run(TestWorker.java:176)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:119)
at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:66)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.run(GradleWorkerMain.java:69)
at worker.org.gradle.process.internal.worker.GradleWorkerMain.main(GradleWorkerMain.java:74)
The code is stored here. The error can be reproduced by running Buffered1ChannelTest.
I am using blocking operations, and for this purpose I created a blockingActor method in the Lincheck library. The corresponding PR is here.
The complete output with the detailed stack trace is in the file output.log
The code is stored here. The error can be reproduced by running
Buffered1ChannelTest
. I am using blocking operations, and for this purpose I created ablockingActor
method in the Lincheck library. The corresponding PR is here.Lincheck version: 2.34 Lincheck plugin version: 0.9 Intellij IDEA version: 2024.2.3