StackOverflow in DispatchedContinuation
See original GitHub issueWe are having a a bug in a class used to instantiate heavy objects in background thread. Seems to happen since bumping coroutines to 1.4.0. Looks like something is cycling in an endless loop. A class:
class AsyncSingletonContainer<T>(scope: CoroutineScope, private val createObject: () -> T) {
private val cachedSingletonObject = scope.async(Dispatchers.Default) { createObject() }
suspend fun getInstance(): T = cachedSingletonObject.await()
}
Stack trace: Fatal Exception: r4.a.i0: Fatal exception in coroutines machinery for DispatchedContinuation[Dispatchers.Default, Continuation at **.AsyncSingletonContainer$cachedSingletonObject$1.invokeSuspend(AsyncSingletonContainer.kt)@f734c38]. Please read KDoc to ‘handleFatalException’ method and report this incident to maintainers at kotlinx.coroutines.DispatchedTask.handleFatalException$kotlinx_coroutines_core(DispatchedTask.java:144) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.java:115) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.java:571) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.java:738) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.java:678) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.java:665)
Caused by java.lang.StackOverflowError: stack size 1037KB at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:452) at java.lang.StringBuilder.append(StringBuilder.java:137) at kotlinx.coroutines.CancellableContinuationImpl.toString(CancellableContinuationImpl.java:506) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.ResumeAwaitOnCompletion.toString(ResumeAwaitOnCompletion.java:1414) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.DisposeOnCancel.toString(DisposeOnCancel.java:385) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.CompletedContinuation.toString(CompletedContinuation.java:18) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.CancellableContinuationImpl.toString(CancellableContinuationImpl.java:506) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.ResumeAwaitOnCompletion.toString(ResumeAwaitOnCompletion.java:1414) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.DisposeOnCancel.toString(DisposeOnCancel.java:385) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.CompletedContinuation.toString(CompletedContinuation.java:18) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.CancellableContinuationImpl.toString(CancellableContinuationImpl.java:506) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.ResumeAwaitOnCompletion.toString(ResumeAwaitOnCompletion.java:1414) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.DisposeOnCancel.toString(DisposeOnCancel.java:385) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.CompletedContinuation.toString(CompletedContinuation.java:18) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.CancellableContinuationImpl.toString(CancellableContinuationImpl.java:506) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.ResumeAwaitOnCompletion.toString(ResumeAwaitOnCompletion.java:1414) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.DisposeOnCancel.toString(DisposeOnCancel.java:385) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.CompletedContinuation.toString(CompletedContinuation.java:18) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.CancellableContinuationImpl.toString(CancellableContinuationImpl.java:506) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.ResumeAwaitOnCompletion.toString(ResumeAwaitOnCompletion.java:1414) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.DisposeOnCancel.toString(DisposeOnCancel.java:385) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.CompletedContinuation.toString(CompletedContinuation.java:18) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.CancellableContinuationImpl.toString(CancellableContinuationImpl.java:506) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.ResumeAwaitOnCompletion.toString(ResumeAwaitOnCompletion.java:1414) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.DisposeOnCancel.toString(DisposeOnCancel.java:385) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.CompletedContinuation.toString(CompletedContinuation.java:18) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.CancellableContinuationImpl.toString(CancellableContinuationImpl.java:506) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.ResumeAwaitOnCompletion.toString(ResumeAwaitOnCompletion.java:1414) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.DisposeOnCancel.toString(DisposeOnCancel.java:385) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.CompletedContinuation.toString(CompletedContinuation.java:18) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.CancellableContinuationImpl.toString(CancellableContinuationImpl.java:506) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.ResumeAwaitOnCompletion.toString(ResumeAwaitOnCompletion.java:1414) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.DisposeOnCancel.toString(DisposeOnCancel.java:385) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.CompletedContinuation.toString(CompletedContinuation.java:18) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.CancellableContinuationImpl.toString(CancellableContinuationImpl.java:506) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.ResumeAwaitOnCompletion.toString(ResumeAwaitOnCompletion.java:1414) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.DisposeOnCancel.toString(DisposeOnCancel.java:385) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.CompletedContinuation.toString(CompletedContinuation.java:18) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.CancellableContinuationImpl.toString(CancellableContinuationImpl.java:506) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.ResumeAwaitOnCompletion.toString(ResumeAwaitOnCompletion.java:1414) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.DisposeOnCancel.toString(DisposeOnCancel.java:385) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.CompletedContinuation.toString(CompletedContinuation.java:18) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.CancellableContinuationImpl.toString(CancellableContinuationImpl.java:506) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.ResumeAwaitOnCompletion.toString(ResumeAwaitOnCompletion.java:1414) at java.lang.String.valueOf(String.java:2827) at java.lang.StringBuilder.append(StringBuilder.java:132) at kotlinx.coroutines.JobSupport.completeStateFinalization(JobSupport.java:320) at kotlinx.coroutines.JobSupport.tryFinalizeSimpleState(JobSupport.java:295) at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.java:853) at kotlinx.coroutines.JobSupport.makeCompletingOnce$kotlinx_coroutines_core(JobSupport.java:825) at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.java:111) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(BaseContinuationImpl.java:46) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.java:106) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.java:571) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.java:738) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.java:678) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.java:665)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:25
- Comments:18 (6 by maintainers)
Top GitHub Comments
Yes. It will a part of 1.4.2
Is there any information when the release comes?