Stacktrace recovery doesn't work for suspend main
See original GitHub issueI took the example https://raw.githubusercontent.com/Kotlin/kotlinx.coroutines/master/kotlinx-coroutines-debug/test/RecoveryExample.kt and add at line 16 a println("${Thread.currentThread().name}")
, so I get
package example
import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
object PublicApiImplementation : CoroutineScope by CoroutineScope(CoroutineName("Example")) {
private fun doWork(): Int {
error("Internal invariant failed")
}
private fun asynchronousWork(): Int {
println("${Thread.currentThread().name}")
return doWork() + 1
}
public suspend fun awaitAsynchronousWorkInMainThread() {
val task = async(Dispatchers.Default) {
asynchronousWork()
}
task.await()
}
}
suspend fun main() {
// Try to switch debug mode on and off to see the difference
PublicApiImplementation.awaitAsynchronousWorkInMainThread()
}
I run it with
- -ea
- -Dkotlinx.coroutines.debug -Dkotlinx.coroutines.stacktrace.recovery=true
- -Dkotlinx.coroutines.debug
I never get an recovered stacktrace. How ever I got
DefaultDispatcher-worker-1 @Example#1
so -Dkotlinx.coroutines.debug
seems to work.
What does I’m missing? Here my version kotlin 1.3.41 coroutines.version 1.2.2
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Stack trace recovery #74 - Kotlin/kotlinx.coroutines - GitHub
As you can see, named suspending functions now execute directly in the the correspondingly named functions on JVM, so the top of the...
Read more >Kotlin coroutines stack trace problem - Libraries
I called it Stacktrace-decoroutinator. My library replaces the coroutine awakening implementation. It generates classes at runtime with names ...
Read more >Kotlin coroutines crash with no helpful stacktrace
I messed up when asking this question and put the emphasis on wrong things. So I'm removing the "retrofit" tag. It turns out...
Read more >Kotlin coroutines stack trace issue - DEV Community
invokeSuspend(main.kt) at kotlin.coroutines.jvm.internal. ... I understand that the stack trace recovery mechanics only work for the case ...
Read more >How to rescue a broken stack trace: Recovering the EBP chain
What happened is that the EBP chain got broken, and the debugger can't walk the stack any further. If the code was compiled...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
As a workaround, you can use
fun main() = runBlocking { ... }
instead ofsuspend fun main()
If you clone https://gitlab.com/ppiag/zulipbot, rename application.properties.sample to application.properties and replace
zulip.url=https://####.zulipchat.com
withzulip.url=https://www.zulipchat.com
and start BotRunner , I guess you have a different situation with ktor and it doesn’t work. Unfortunately it’s not so easy to debug 😦Any idea when 1.3 will be released or a beta for a test?