Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat first actor (operation) as regular method call #452

Open
eupp opened this issue Jan 28, 2025 · 2 comments
Open

Treat first actor (operation) as regular method call #452

eupp opened this issue Jan 28, 2025 · 2 comments

Comments

@eupp
Copy link
Collaborator

eupp commented Jan 28, 2025

On the following test

class RecursiveSpinLockRepeatsOperationTest {
    private val value = AtomicBoolean(false)

    fun foo() {
        if (value.get()) return
        foo()
    }

    @Test
    fun test() = ModelCheckingOptions()
        .iterations(0)
        .addCustomScenario { parallel { thread { actor(::foo) } } }
        .checkImpl(this::class.java)
        .checkLincheckOutput("spin_lock/recursive_spin_lock_repeats_operation.txt")
}

Lincheck produces an incorrect spin-lock

The following interleaving leads to the error:
| ------------------------------------------------------------------------------------------------- |
|                                             Thread 1                                              |
| ------------------------------------------------------------------------------------------------- |
|   foo(): <hung>                                                                                   |
|     /* The following events repeat infinitely: */                                                 |
| ┌╶> value.get(): false at RecursiveSpinLockRepeatsOperationTest.foo(RecursiveSpinLockTest.kt:301) |
| └╶╶ switch (reason: active lock detected)                                                         |
| ------------------------------------------------------------------------------------------------- |
All unfinished threads are in deadlock
@eupp
Copy link
Collaborator Author

eupp commented Jan 28, 2025

Draft PR #453

@ndkoval ndkoval removed the bug label Feb 6, 2025
@eupp
Copy link
Collaborator Author

eupp commented Feb 6, 2025

The problem is because in the ManagedStrategy class we treat the top-most function (the actor) not as a regular method call. We should refactor this to prevent this bug and similar bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants