Skip to content

Commit

Permalink
add opt-in annotation for the experimental API
Browse files Browse the repository at this point in the history
Signed-off-by: Evgeniy Moiseenko <[email protected]>
  • Loading branch information
eupp committed Jan 24, 2025
1 parent 9325fe5 commit 67a4efe
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 36 deletions.
6 changes: 6 additions & 0 deletions src/jvm/main/org/jetbrains/kotlinx/lincheck/Lincheck.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,19 @@ import org.jetbrains.kotlinx.lincheck.verifier.Verifier
import org.jetbrains.kotlinx.lincheck.strategy.verify


@RequiresOptIn(message = "The model checking API is experimental and could change in the future.")
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.FUNCTION)
annotation class ExperimentalModelCheckingAPI

/**
* This method will explore different interleavings of the [block] body and all the threads created within it,
* searching for the first raised exception.
*
* @param invocations number of different interleavings of code in the [block] that should be explored.
* @param block lambda which body will be a target for the interleavings exploration.
*/
@ExperimentalModelCheckingAPI
fun <R> runConcurrentTest(
invocations: Int = DEFAULT_INVOCATIONS_COUNT,
block: () -> R
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
* with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

@file:OptIn(ExperimentalModelCheckingAPI::class)

package org.jetbrains.kotlinx.lincheck_test.representation

import org.jetbrains.kotlinx.lincheck.ExperimentalModelCheckingAPI
import org.jetbrains.kotlinx.lincheck.runConcurrentTest
import org.jetbrains.kotlinx.lincheck.LincheckAssertionError
import org.jetbrains.kotlinx.lincheck.util.UnsafeHolder
Expand All @@ -21,7 +24,6 @@ import kotlin.concurrent.thread
import kotlin.random.Random
import org.junit.Test


abstract class BaseRunConcurrentRepresentationTest<R>(private val outputFileName: String) {
/**
* Implement me and place the logic to check its trace.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,49 +13,49 @@ The following interleaving leads to the error:
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Thread 1 |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| AtomicReferencesNamesRunConcurrentRepresentationTest#1.block(): threw IllegalStateException at BaseRunConcurrentRepresentationTest$testRunWithModelChecker$result$1$1.invoke(RunConcurrentRepresentationTests.kt:35) |
| AtomicReferencesNamesRunConcurrentRepresentationTest#1.block(): threw IllegalStateException at BaseRunConcurrentRepresentationTest$testRunWithModelChecker$result$1$1.invoke(RunConcurrentRepresentationTests.kt:37) |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

Exception stack traces:
#1: java.lang.IllegalStateException: Check failed.
at org.jetbrains.kotlinx.lincheck_test.representation.AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:102)
at org.jetbrains.kotlinx.lincheck_test.representation.AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:65)
at org.jetbrains.kotlinx.lincheck_test.representation.BaseRunConcurrentRepresentationTest$testRunWithModelChecker$result$1$1.invoke(RunConcurrentRepresentationTests.kt:35)
at org.jetbrains.kotlinx.lincheck_test.representation.AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:106)
at org.jetbrains.kotlinx.lincheck_test.representation.AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:69)
at org.jetbrains.kotlinx.lincheck_test.representation.BaseRunConcurrentRepresentationTest$testRunWithModelChecker$result$1$1.invoke(RunConcurrentRepresentationTests.kt:37)
at java.base/java.lang.Thread.run(Thread.java:840)

Detailed trace:
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Thread 1 |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| AtomicReferencesNamesRunConcurrentRepresentationTest#1.block(): threw IllegalStateException at BaseRunConcurrentRepresentationTest$testRunWithModelChecker$result$1$1.invoke(RunConcurrentRepresentationTests.kt:35) |
| block(): threw IllegalStateException at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:65) |
| AtomicReference#1.get(): Node#1 at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:70) |
| AtomicReference#1.compareAndSet(Node#1,Node#2): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:70) |
| AtomicReference#1.set(Node#3) at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:71) |
| AtomicInteger#1.get(): 0 at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:73) |
| AtomicInteger#1.compareAndSet(0,2): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:73) |
| AtomicInteger#1.set(3) at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:74) |
| AtomicLong#1.get(): 0 at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:76) |
| AtomicLong#1.compareAndSet(0,2): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:76) |
| AtomicLong#1.set(3) at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:77) |
| AtomicBoolean#1.get(): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:79) |
| AtomicBoolean#1.compareAndSet(true,true): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:79) |
| AtomicBoolean#1.set(false) at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:80) |
| AtomicReferenceArray#1[0].get(): Node#4 at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:82) |
| AtomicReferenceArray#1[0].compareAndSet(Node#4,Node#5): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:82) |
| AtomicReferenceArray#1[0].set(Node#6) at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:83) |
| AtomicIntegerArray#1[0].get(): 0 at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:85) |
| AtomicIntegerArray#1[0].compareAndSet(0,1): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:85) |
| AtomicIntegerArray#1[0].set(2) at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:86) |
| AtomicLongArray#1[0].get(): 0 at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:88) |
| AtomicLongArray#1[0].compareAndSet(0,1): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:88) |
| AtomicLongArray#1[0].set(2) at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:89) |
| AtomicReference#2.set(Node#7) at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:91) |
| AtomicIntegerArray#2[0].compareAndSet(1,2): false at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:92) |
| AtomicInteger#2.compareAndSet(0,2): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:94) |
| AtomicInteger#2.set(0) at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:95) |
| AtomicInteger#3.compareAndSet(1,2): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:97) |
| AtomicInteger#3.set(3) at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:98) |
| AtomicIntegerArray#3[1].compareAndSet(0,1): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:100) |
| AtomicIntegerArray#4[1].compareAndSet(0,1): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:101) |
| AtomicReferencesNamesRunConcurrentRepresentationTest#1.block(): threw IllegalStateException at BaseRunConcurrentRepresentationTest$testRunWithModelChecker$result$1$1.invoke(RunConcurrentRepresentationTests.kt:37) |
| block(): threw IllegalStateException at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:69) |
| AtomicReference#1.get(): Node#1 at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:74) |
| AtomicReference#1.compareAndSet(Node#1,Node#2): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:74) |
| AtomicReference#1.set(Node#3) at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:75) |
| AtomicInteger#1.get(): 0 at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:77) |
| AtomicInteger#1.compareAndSet(0,2): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:77) |
| AtomicInteger#1.set(3) at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:78) |
| AtomicLong#1.get(): 0 at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:80) |
| AtomicLong#1.compareAndSet(0,2): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:80) |
| AtomicLong#1.set(3) at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:81) |
| AtomicBoolean#1.get(): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:83) |
| AtomicBoolean#1.compareAndSet(true,true): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:83) |
| AtomicBoolean#1.set(false) at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:84) |
| AtomicReferenceArray#1[0].get(): Node#4 at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:86) |
| AtomicReferenceArray#1[0].compareAndSet(Node#4,Node#5): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:86) |
| AtomicReferenceArray#1[0].set(Node#6) at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:87) |
| AtomicIntegerArray#1[0].get(): 0 at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:89) |
| AtomicIntegerArray#1[0].compareAndSet(0,1): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:89) |
| AtomicIntegerArray#1[0].set(2) at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:90) |
| AtomicLongArray#1[0].get(): 0 at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:92) |
| AtomicLongArray#1[0].compareAndSet(0,1): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:92) |
| AtomicLongArray#1[0].set(2) at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:93) |
| AtomicReference#2.set(Node#7) at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:95) |
| AtomicIntegerArray#2[0].compareAndSet(1,2): false at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:96) |
| AtomicInteger#2.compareAndSet(0,2): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:98) |
| AtomicInteger#2.set(0) at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:99) |
| AtomicInteger#3.compareAndSet(1,2): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:101) |
| AtomicInteger#3.set(3) at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:102) |
| AtomicIntegerArray#3[1].compareAndSet(0,1): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:104) |
| AtomicIntegerArray#4[1].compareAndSet(0,1): true at AtomicReferencesNamesRunConcurrentRepresentationTest.block(RunConcurrentRepresentationTests.kt:105) |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

0 comments on commit 67a4efe

Please sign in to comment.