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

Track coroutine events in arbitrary code #260

Open
eupp opened this issue Jan 18, 2024 · 3 comments
Open

Track coroutine events in arbitrary code #260

eupp opened this issue Jan 18, 2024 · 3 comments

Comments

@eupp
Copy link
Collaborator

eupp commented Jan 18, 2024

Currently, the Lincheck supports only top-level suspend functions declared as operations.

That is, the following code is supported:

class RendezvousChannelTest {
    private val channel = Channel<Int>()

    @Operation
    suspend fun send(value: Int) = channel.send(value)
    
    ...
    
}

But the coroutines launched by the user code are not tracked and thus may work incorrectly.
For example, the following code may not work as expected:

class LaunchTest {

    @Operation
    fun do(value: Int) {
       launch { ... }
    }
    
    ...
    
}

In order to support the latter case, the Lincheck need to be able to intercept coroutine's events (suspension, resumption, etc) in an arbitrary code.

Pros:

  • Being able to run arbitrary code with coroutines support leads to a simpler and more intuitive behavior from the user's point of view.

Cons:

  • Currently, the primary use case of Lincheck is to test concurrent data structures and synchronization primitives. This type of code rarely requires to create custom coroutines inside operations.
@ndkoval
Copy link
Collaborator

ndkoval commented Jan 19, 2024

@eupp, why would a data structure launch a coroutine?

@eupp
Copy link
Collaborator Author

eupp commented Jan 22, 2024

why would a data structure launch a coroutine?

I mentioned that this is unlikely case:

Currently, the primary use case of Lincheck is to test concurrent data structures and synchronization primitives. This type of code rarely requires to create custom coroutines inside operations.

But I would rather prefer to keep this as a tracking issue, in case we discover such cases later (or users will report something related).

@eupp eupp added the enhancement New feature or request label Sep 25, 2024
@eupp
Copy link
Collaborator Author

eupp commented Sep 25, 2024

We might need to revisit this problem under #386

@ndkoval ndkoval added general-purpose mc and removed enhancement New feature or request labels Sep 25, 2024
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