Hi everyone! I am facing a strange error while I r...
# coroutines
d
Hi everyone! I am facing a strange error while I run the
nativeTest
task in a multi-platform project (using coroutines
1.5.2-native-mt
). I use
runBlocking
around each of my tests. This works correctly when I run each test independently one by one. But when I run the whole test suite, at the start of the second test, I get
Uncaught Kotlin exception: kotlin.IllegalStateException: Cannot execute task because event loop was shut down
(full stack-trace in thread). Did anyone ever faced this?
The full stack-trace:
Copy code
Uncaught Kotlin exception: kotlin.IllegalStateException: Cannot execute task because event loop was shut down
    at kfun:kotlin.Throwable#<init>(kotlin.String?){} (0x41da0b)
    at kfun:kotlin.Exception#<init>(kotlin.String?){} (0x417987)
    at kfun:kotlin.RuntimeException#<init>(kotlin.String?){} (0x417b07)
    at kfun:kotlin.IllegalStateException#<init>(kotlin.String?){} (0x417d77)
    at kfun:kotlinx.coroutines#loopWasShutDown(){}kotlin.Nothing (0x5de646)
    at kfun:kotlinx.coroutines.DefaultExecutor#enqueue(kotlinx.coroutines.Runnable){} (0x5de373)
    at kfun:kotlinx.coroutines.EventLoopImplBase#enqueue(kotlinx.coroutines.Runnable){} (0x561d26)
    at kfun:kotlinx.coroutines.EventLoopImplBase#dispatch(kotlin.coroutines.CoroutineContext;kotlinx.coroutines.Runnable){} (0x561c43)
    at kfun:kotlinx.coroutines.internal.DispatchedContinuation#resumeWith(kotlin.Result<1:0>){} (0x5b6f4e)
    at kfun:kotlinx.coroutines#resume__at__kotlinx.coroutines.CancellableContinuationImpl<0:0>(kotlin.coroutines.Continuation<0:0>;kotlin.Boolean){0§<kotlin.Any?>} (0x5ba30b)
    at kfun:kotlinx.coroutines.internal.shareableResume$lambda-1#internal (0x5ebebe)
    at kfun:kotlinx.coroutines.internal.$shareableResume$lambda-1$FUNCTION_REFERENCE$67.invoke#internal (0x5ec22d)
    at kfun:kotlinx.coroutines.internal.$shareableResume$lambda-1$FUNCTION_REFERENCE$67.$<bridge-UNN>invoke(){}#internal (0x5ec3bd)
    at WorkerLaunchpad (0x44994f)
    at _ZN6Worker19processQueueElementEb (0x80f4a4)
    at _ZN6Worker4parkElb (0x810add)
    at kfun:kotlin.native.concurrent.Worker#park(kotlin.Long;kotlin.Boolean){}kotlin.Boolean (0x44ce96)
    at kfun:kotlinx.coroutines.WorkerThread#parkNanos(kotlin.Long){} (0x5e2dc8)
    at kfun:kotlinx.coroutines#runEventLoop(kotlinx.coroutines.EventLoop?;kotlin.Function0<kotlin.Boolean>){} (0x5db635)
    at kfun:kotlinx.coroutines.BlockingCoroutine.joinBlocking#internal (0x5dcabd)
    at kfun:kotlinx.coroutines#runBlocking(kotlin.coroutines.CoroutineContext;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,0:0>){0§<kotlin.Any?>}0:0 (0x5dc092)
    at kfun:org.zeromq.tests.utils#testSuspend(kotlin.coroutines.CoroutineContext;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,kotlin.Unit>){} (0x72a686)
    at kfun:org.zeromq.tests.utils#testSuspend$default(kotlin.coroutines.CoroutineContext?;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,kotlin.Unit>;kotlin.Int){} (0x72a7ce)
    at kfun:org.zeromq.tests.utils#testWithEngine(org.zeromq.Engine;kotlin.coroutines.SuspendFunction1<org.zeromq.tests.utils.TestContextBuilder,kotlin.Unit>){} (0x725a23)
    at kfun:org.zeromq.tests.utils#contextTests(kotlin.collections.List<kotlin.String>;kotlin.coroutines.SuspendFunction1<org.zeromq.tests.utils.TestContextBuilder,kotlin.Unit>){} (0x724665)
    at kfun:org.zeromq.tests.utils#contextTests$default(kotlin.collections.List<kotlin.String>?;kotlin.coroutines.SuspendFunction1<org.zeromq.tests.utils.TestContextBuilder,kotlin.Unit>;kotlin.Int){} (0x724f3e)
    at kfun:org.zeromq.tests.sockets.PubSubTests#connectBindTest(){} (0x72aa3c)
    at kfun:org.zeromq.tests.sockets.$PubSubTests$test$0.$connectBindTest$FUNCTION_REFERENCE$1.invoke#internal (0x73b675)
    at kfun:org.zeromq.tests.sockets.$PubSubTests$test$0.$connectBindTest$FUNCTION_REFERENCE$1.$<bridge-UNNN>invoke(-1:0){}#internal (0x73b86b)
    at kfun:kotlin.native.internal.test.BaseClassSuite.TestCase#run(){} (0x472c5c)
    at kfun:kotlin.native.internal.test.TestRunner.run#internal (0x46a0bb)
    at kfun:kotlin.native.internal.test.TestRunner.runIteration#internal (0x46c8ba)
    at kfun:kotlin.native.internal.test.TestRunner#run(){}<http://kotlin.Int|kotlin.Int> (0x46da5b)
    at kfun:kotlin.native.internal.test#testLauncherEntryPoint(kotlin.Array<kotlin.String>){}<http://kotlin.Int|kotlin.Int> (0x45dece)
    at kfun:kotlin.native.internal.test#main(kotlin.Array<kotlin.String>){} (0x45dd89)
    at Konan_start (0x45dffd)
    at Init_and_run_start (0x7fd670)
    at __libc_start_main (0x7f2d36d57b75)
    at  (0x405d31)
    at  ((nil))
kotlinx.coroutines.CompletionHandlerException: Exception in completion handler ResumeOnCompletion@e08588[job@e0c3f8] for JobImpl{Cancelled}@e0c3f8
    at kfun:kotlin.Exception#<init>(kotlin.String?;kotlin.Throwable?){} (0x417a15)
    at kfun:kotlin.RuntimeException#<init>(kotlin.String?;kotlin.Throwable?){} (0x417b95)
    at kfun:kotlinx.coroutines.CompletionHandlerException#<init>(kotlin.String;kotlin.Throwable){} (0x5660d5)
    at kfun:kotlinx.coroutines.JobSupport.notifyCompletion#internal (0x56dc76)
    at kfun:kotlinx.coroutines.JobSupport.completeStateFinalization#internal (0x56c7b8)
    at kfun:kotlinx.coroutines.JobSupport.finalizeFinishingState#internal (0x56a401)
    at kfun:kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath#internal (0x576b91)
    at kfun:kotlinx.coroutines.JobSupport.tryMakeCompleting#internal (0x5762d3)
    at kfun:kotlinx.coroutines.JobSupport#makeCompleting(kotlin.Any?){}kotlin.Boolean (0x5759f4)
    at kfun:kotlinx.coroutines.JobImpl#completeExceptionally(kotlin.Throwable){}kotlin.Boolean (0x57f8ed)
    at kfun:io.ktor.utils.io.internal.AwaitingSlot#cancel(kotlin.Throwable?){} (0x67ee2a)
    at kfun:io.ktor.utils.io.ByteChannelSequentialBase#close(kotlin.Throwable?){}kotlin.Boolean (0x610159)
    at kfun:io.ktor.utils.io.ByteChannelNative#close(kotlin.Throwable?){}kotlin.Boolean (0x6844e5)
    at kfun:io.ktor.utils.io.ByteChannelSequentialBase#cancel(kotlin.Throwable?){}kotlin.Boolean (0x60fea4)
    at kfun:io.ktor.utils.io.$launchChannel$lambda-0COROUTINE$160.invokeSuspend#internal (0x619126)
    at kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} (0x43d0a0)
    at kfun:kotlinx.coroutines.internal.DispatchedContinuation#resumeWith(kotlin.Result<1:0>){} (0x5b7187)
    at kfun:kotlinx.coroutines#resume__at__kotlinx.coroutines.CancellableContinuationImpl<0:0>(kotlin.coroutines.Continuation<0:0>;kotlin.Boolean){0§<kotlin.Any?>} (0x5ba30b)
    at kfun:kotlinx.coroutines.internal.shareableResume$lambda-1#internal (0x5ebebe)
    at kfun:kotlinx.coroutines.internal.$shareableResume$lambda-1$FUNCTION_REFERENCE$67.invoke#internal (0x5ec22d)
    at kfun:kotlinx.coroutines.internal.$shareableResume$lambda-1$FUNCTION_REFERENCE$67.$<bridge-UNN>invoke(){}#internal (0x5ec3bd)
    at WorkerLaunchpad (0x44994f)
    at _ZN6Worker19processQueueElementEb (0x80f4a4)
    at _ZN6Worker4parkElb (0x810add)
    at kfun:kotlin.native.concurrent.Worker#park(kotlin.Long;kotlin.Boolean){}kotlin.Boolean (0x44ce96)
    at kfun:kotlinx.coroutines.WorkerThread#parkNanos(kotlin.Long){} (0x5e2dc8)
    at kfun:kotlinx.coroutines#runEventLoop(kotlinx.coroutines.EventLoop?;kotlin.Function0<kotlin.Boolean>){} (0x5db635)
    at kfun:kotlinx.coroutines.BlockingCoroutine.joinBlocking#internal (0x5dcabd)
    at kfun:kotlinx.coroutines#runBlocking(kotlin.coroutines.CoroutineContext;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,0:0>){0§<kotlin.Any?>}0:0 (0x5dc092)
    at kfun:org.zeromq.tests.utils#testSuspend(kotlin.coroutines.CoroutineContext;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,kotlin.Unit>){} (0x72a686)
    at kfun:org.zeromq.tests.utils#testSuspend$default(kotlin.coroutines.CoroutineContext?;kotlin.coroutines.SuspendFunction1<kotlinx.coroutines.CoroutineScope,kotlin.Unit>;kotlin.Int){} (0x72a7ce)
    at kfun:org.zeromq.tests.utils#testWithEngine(org.zeromq.Engine;kotlin.coroutines.SuspendFunction1<org.zeromq.tests.utils.TestContextBuilder,kotlin.Unit>){} (0x725a23)
    at kfun:org.zeromq.tests.utils#contextTests(kotlin.collections.List<kotlin.String>;kotlin.coroutines.SuspendFunction1<org.zeromq.tests.utils.TestContextBuilder,kotlin.Unit>){} (0x724665)
    at kfun:org.zeromq.tests.utils#contextTests$default(kotlin.collections.List<kotlin.String>?;kotlin.coroutines.SuspendFunction1<org.zeromq.tests.utils.TestContextBuilder,kotlin.Unit>;kotlin.Int){} (0x724f3e)
    at kfun:org.zeromq.tests.sockets.PubSubTests#connectBindTest(){} (0x72aa3c)
    at kfun:org.zeromq.tests.sockets.$PubSubTests$test$0.$connectBindTest$FUNCTION_REFERENCE$1.invoke#internal (0x73b675)
    at kfun:org.zeromq.tests.sockets.$PubSubTests$test$0.$connectBindTest$FUNCTION_REFERENCE$1.$<bridge-UNNN>invoke(-1:0){}#internal (0x73b86b)
    at kfun:kotlin.native.internal.test.BaseClassSuite.TestCase#run(){} (0x472c5c)
    at kfun:kotlin.native.internal.test.TestRunner.run#internal (0x46a0bb)
    at kfun:kotlin.native.internal.test.TestRunner.runIteration#internal (0x46c8ba)
    at kfun:kotlin.native.internal.test.TestRunner#run(){}<http://kotlin.Int|kotlin.Int> (0x46da5b)
    at kfun:kotlin.native.internal.test#testLauncherEntryPoint(kotlin.Array<kotlin.String>){}<http://kotlin.Int|kotlin.Int> (0x45dece)
    at kfun:kotlin.native.internal.test#main(kotlin.Array<kotlin.String>){} (0x45dd89)
    at Konan_start (0x45dffd)
    at Init_and_run_start (0x7fd670)
    at __libc_start_main (0x7f2d36d57b75)
    at  (0x405d31)
    at  ((nil))
Caused by: kotlin.IllegalStateException: Cannot execute task because event loop was shut down
    at kfun:kotlin.Throwable#<init>(kotlin.String?){} (0x41da0b)
    at kfun:kotlin.Exception#<init>(kotlin.String?){} (0x417987)
    at kfun:kotlin.RuntimeException#<init>(kotlin.String?){} (0x417b07)
    at kfun:kotlin.IllegalStateException#<init>(kotlin.String?){} (0x417d77)
    at kfun:kotlinx.coroutines#loopWasShutDown(){}kotlin.Nothing (0x5de646)
    at kfun:kotlinx.coroutines.DefaultExecutor#enqueue(kotlinx.coroutines.Runnable){} (0x5de373)
    at kfun:kotlinx.coroutines.EventLoopImplBase#enqueue(kotlinx.coroutines.Runnable){} (0x561d26)
    at kfun:kotlinx.coroutines.EventLoopImplBase#dispatch(kotlin.coroutines.CoroutineContext;kotlinx.coroutines.Runnable){} (0x561c43)
    at kfun:kotlinx.coroutines#dispatch__at__kotlinx.coroutines.CancellableContinuationImpl<0:0>(<http://kotlin.Int|kotlin.Int>){0§<kotlin.Any?>} (0x5b9892)
    at kfun:kotlinx.coroutines.CancellableContinuationImpl.dispatchResume#internal (0x554bcd)
    at kfun:kotlinx.coroutines.CancellableContinuationImpl.resumeImpl#internal (0x5554af)
    at kfun:kotlinx.coroutines.CancellableContinuationImpl#resumeImpl$default(kotlin.Any?;kotlin.Int;kotlin.Function1<kotlin.Throwable,kotlin.Unit>?;kotlin.Int){} (0x555782)
    at kfun:kotlinx.coroutines.CancellableContinuationImpl#resumeWith(kotlin.Result<1:0>){} (0x55396e)
    at kfun:kotlinx.coroutines.ResumeOnCompletion.invoke#internal (0x57e8b4)
    at kfun:kotlinx.coroutines.JobSupport.notifyCompletion#internal (0x56da9e)
    at kfun:kotlinx.coroutines.JobSupport.completeStateFinalization#internal (0x56c7b8)
    ... and 43 more common stack frames skipped
Uncaught Kotlin exception: kotlin.Throwable: The process was terminated due to the unhandled exception thrown in the coroutine [StandaloneCoroutine{Cancelling}@e07918, Dispatchers.Unconfined]: Exception in completion handler ResumeOnCompletion@e1b068[job@e06f58] for JobImpl{Cancelled}@e06f58
    at kfun:kotlinx.coroutines#handleCoroutineExceptionImpl(kotlin.coroutines.CoroutineContext;kotlin.Throwable){} (0x5deaad)
    at kfun:kotlinx.coroutines#handleCoroutineException(kotlin.coroutines.CoroutineContext;kotlin.Throwable){} (0x55c480)
    at kfun:kotlinx.coroutines.StandaloneCoroutine.handleJobException#internal (0x54d2a5)
    at kfun:kotlinx.coroutines.JobSupport.finalizeFinishingState#internal (0x56a6e8)
    at kfun:kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath#internal (0x576b91)
    at kfun:kotlinx.coroutines.JobSupport.tryMakeCompleting#internal (0x5762d3)
    at kfun:kotlinx.coroutines.JobSupport#makeCompletingOnce(kotlin.Any?){}kotlin.Any? (0x575d98)
    at kfun:kotlinx.coroutines.AbstractCoroutine#resumeWith(kotlin.Result<1:0>){} (0x54c454)
    at kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} (0x43d3b5)
[...]