Skip to content

Coroutine is not visible in DebugProbes if it was not suspended #3383

Open
@dovchinnikov

Description

@dovchinnikov

JVM: Liberica 11.0.14.1
kotlinx-coroutines-jdk8 1.6.2
kotlinx-coroutines-debug 1.6.2

The following program

import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.awaitCancellation
import kotlinx.coroutines.debug.DebugProbes
import kotlinx.coroutines.launch

fun main() {
  DebugProbes.enableCreationStackTraces = false
  DebugProbes.install()
  GlobalScope.launch {
    launch {
      awaitCancellation()
    }
  }
  Thread.sleep(100)
  DebugProbes.dumpCoroutines()
  println()
  println("-----")

  for (coroutineInfo in DebugProbes.dumpCoroutinesInfo()) {
    println(coroutineInfo)
  }
}

prints

Coroutines dump 2022/07/28 16:04:10

Coroutine "coroutine#2":StandaloneCoroutine{Active}@49070868, state: SUSPENDED
	at kotlinx.coroutines.DelayKt.awaitCancellation(Delay.kt:148)
	at com.intellij.diagnostic.DebugprobestestKt$main$1$1.invokeSuspend(debugprobestest.kt:14)
-----
CoroutineInfo(state=SUSPENDED,context=[CoroutineId(2), "coroutine#2":StandaloneCoroutine{Active}@49070868, Dispatchers.Default])

I'd expect to see the root coroutine somewhere in the dump, it "hangs" because its child is not completed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions