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

delays in coroutines make gpmc detect unfinished threads deadlock #543

Open
dmitrii-artuhov opened this issue Feb 21, 2025 · 0 comments
Open

Comments

@dmitrii-artuhov
Copy link
Collaborator

dmitrii-artuhov commented Feb 21, 2025

GPMC incorrectly handles the delay's in the coroutine bodies.
Relates to #390

Problem

MInimal reproducing test:

@OptIn(ExperimentalModelCheckingAPI::class)
    @Test
    fun test() {
        runConcurrentTest(1000) {
            val pool = Executors.newFixedThreadPool(2).asCoroutineDispatcher()
            pool.use {
                runBlocking(pool) {
                    val nElements = 2
                    val channel = Channel<Int>() // RENDEZVOUS

                    launch(pool) {
                        for (i in 1..nElements) {
                            channel.send(i)
                            delay(1 /* ms */)
                        }
                        channel.close()
                    }

                    for (i in 1..nElements) {
                        val element = channel.receive()
                        check(element == i)
                    }
                }
            }
        }
    }

GPMC reports:

...
All unfinished threads are in deadlock

Expected

  • Execution should not hang
  • ?? delay's should be no-op ??
@dmitrii-artuhov dmitrii-artuhov changed the title delays in coroutines makes gpmc detect unfinished threads deadlock delays in coroutines make gpmc detect unfinished threads deadlock Feb 21, 2025
@ndkoval ndkoval added this to the GPMC: Private Release milestone Feb 28, 2025
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