Amritansh
11/11/2020, 1:32 AMUncaught Kotlin exception: kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for DispatchedContinuation[MainDispatcher, Continuation @ $postRequest$lambda-1COROUTINE$1]. Please read KDoc to 'handleFatalException' method and report this incident to maintainers
at 0 shared 0x0000000103e8730c kfun:kotlin.Error#<init>(kotlin.String?;kotlin.Throwable?){} + 124 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/Exceptions.kt:14:63)
at 1 shared 0x0000000103ffa913 kfun:kotlinx.coroutines.CoroutinesInternalError#<init>(kotlin.String;kotlin.Throwable){} + 115 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/Exceptions.common.kt:28:77)
at 2 shared 0x0000000104042bfa kfun:kotlinx.coroutines.DispatchedTask#handleFatalException(kotlin.Throwable?;kotlin.Throwable?){} + 938 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/internal/DispatchedTask.kt:93:22)
at 3 shared 0x00000001040427e8 kfun:kotlinx.coroutines.DispatchedTask#run(){} + 3512 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/internal/DispatchedTask.kt:64:13)
at 4 shared 0x000000010406b0f5 kfun:kotlinx.coroutines.DarwinMainDispatcher.dispatch$lambda-0#internal + 85 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/nativeDarwin/src/Dispatchers.kt:35:19)
at 5 shared 0x000000010406b4ab kfun:kotlinx.coroutines.DarwinMainDispatcher.$dispatch$lambda-0$FUNCTION_REFERENCE$43.invoke#internal + 59 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/nativeDarwin/src/Dispatchers.kt:34:51)
at 6 shared 0x000000010406b50b kfun:kotlinx.coroutines.DarwinMainDispatcher.$dispatch$lambda-0$FUNCTION_REFERENCE$43.$<bridge-UNN>invoke(){}#internal + 59 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/nativeDarwin/src/Dispatchers.kt:34:51)
at 7 shared 0x000000010406c5c4 _6f72672e6a6574627261696e732e6b6f746c696e783a6b6f746c696e782d636f726f7574696e65732d636f7265_knbridge8 + 180 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/nativeDarwin/src/Dispatchers.kt:34:51)
at 8 libdispatch.dylib 0x0000000104983dd4 _dispatch_call_block_and_release + 12
at 9 libdispatch.dylib 0x0000000104984d48 _dispatch_client_callout + 8
at 10 libdispatch.dylib 0x0000000104992de6 _dispatch_main_queue_callback_4CF + 1500
at 11 CoreFoundation 0x00007fff23bd4049 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
at 12 CoreFoundation 0x00007fff23bceca9 __CFRunLoopRun + 2329
at 13 CoreFoundation 0x00007fff23bce066 CFRunLoopRunSpecific + 438
at 14 GraphicsServices 0x00007fff384c0bb0 GSEventRunModal + 65
at 15 UIKitCore 0x00007fff48092d4d UIApplicationMain + 1621
at 16 iosApp-sample 0x0000000103b0405b main + 75 (/Users/atripathi/shared/iosApp-sample/iosApp-sample/AppDelegate.swift:4:7)
at 17 libdyld.dylib 0x00007fff5227ec25 start + 1
Caused by: kotlin.native.IncorrectDereferenceException: Trying to access top level value not marked as @ThreadLocal or @SharedImmutable from non-main thread
at 0 shared 0x0000000103e8e52d kfun:kotlin.Throwable#<init>(kotlin.String?){} + 93 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/Throwable.kt:23:37)
at 1 shared 0x0000000103e8741b kfun:kotlin.Exception#<init>(kotlin.String?){} + 91 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/Exceptions.kt:23:44)
at 2 shared 0x0000000103e875db kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 91 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/Exceptions.kt:34:44)
at 3 shared 0x0000000103eba3db kfun:kotlin.native.IncorrectDereferenceException#<init>(kotlin.String){} + 91 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/native/Runtime.kt:30:36)
at 4 shared 0x0000000103edbb61 ThrowIncorrectDereferenceException + 129 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/native/internal/RuntimeUtils.kt:103:11)
at 5 shared 0x0000000103fc5c89 CheckIsMainThread + 25
at 6 shared 0x00000001041a57e3 kfun:io.ktor.http.<get-HeaderFieldValueSeparators>#internal + 19 (/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-http/common/src/io/ktor/http/HeaderValueWithParameters.kt:10:9)
at 7 shared 0x00000001041a6e24 kfun:io.ktor.http.checkNeedEscape#internal + 356 (/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-http/common/src/io/ktor/http/HeaderValueWithParameters.kt:86:13)
at 8 shared 0x00000001041a65d5 kfun:io.ktor.http.HeaderValueWithParameters#toString(){}kotlin.String + 2101 (/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-http/common/src/io/ktor/http/HeaderValueWithParameters.kt:41:21)
at 9 shared 0x00000001041fb0f7 kfun:io.ktor.client.engine#mergeHeaders(io.ktor.http.Headers;io.ktor.http.content.OutgoingContent;kotlin.Function2<kotlin.String,kotlin.String,kotlin.Unit>){} + 3095 (/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-client/ktor-client-core/common/src/io/ktor/client/engine/Utils.kt:45:37)
at 10 shared 0x000000010423adfe kfun:io.ktor.client.engine.ios.IosClientEngine.$executeCOROUTINE$0#invokeSuspend(kotlin.Result<kotlin.Any?>){}kotlin.Any? + 5630 (/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-client/ktor-client-ios/darwin/src/io/ktor/client/engine/ios/IosClientEngine.kt:40:13)
at 11 shared 0x000000010423c2a4 kfun:io.ktor.client.engine.ios.IosClientEngine#execute(io.ktor.client.request.HttpRequestData){}io.ktor.client.request.HttpResponseData + 308 (/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-client/ktor-client-ios/darwin/src/io/ktor/client/engine/ios/IosClientEngine.kt:21:22)
at 12 shared 0x00000001041f813b kfun:io.ktor.client.engine.HttpClientEngine.$executeWithinCallContext$lambda-1COROUTINE$11.invokeSuspend#internal + 731 (/Users/administrator/Documents/agent/work/8d547b974a7be21f/ktor-client/ktor-client-core/common/src/io/ktor/client/engine/HttpClientEngine.kt:86:13)
at 13 shared 0x0000000103eafc16 kfun:kotlin.coroutines.native.internal.BaseContinuationImpl#resumeWith(kotlin.Result<kotlin.Any?>){} + 758 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/coroutines/ContinuationImpl.kt:30:39)
at 14 shared 0x00000001040424ff kfun:kotlinx.coroutines.DispatchedTask#run(){} + 2767 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/internal/DispatchedTask.kt:39:50)
at 15 shared 0x0000000103ff5ecf kfun:kotlinx.coroutines.EventLoopImplBase#processNextEvent(){}kotlin.Long + 799 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/EventLoop.common.kt:274:18)
at 16 shared 0x000000010405a228 kfun:kotlinx.coroutines#runEventLoop(kotlinx.coroutines.EventLoop?;kotlin.Function0<kotlin.Boolean>){} + 872 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/native/src/Builders.kt:80:40)
at 17 shared 0x0000000104062b85 kfun:kotlinx.coroutines.WorkerCoroutineDispatcherImpl.start$lambda-0#internal + 389 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/native/src/Workers.kt:49:17)
at 18 shared 0x0000000104062d5b kfun:kotlinx.coroutines.WorkerCoroutineDispatcherImpl.$start$lambda-0$FUNCTION_REFERENCE$35.invoke#internal + 59 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/native/src/Workers.kt:47:24)
at 19 shared 0x0000000104062dbb kfun:kotlinx.coroutines.WorkerCoroutineDispatcherImpl.$start$lambda-0$FUNCTION_REFERENCE$35.$<bridge-UNN>invoke(){}#internal + 59 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/native/src/Workers.kt:47:24)
at 20 shared 0x0000000103ebdfe7 WorkerLaunchpad + 183 (/Users/teamcity/buildAgent/work/cae0e6559deed4c4/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt:69:54)
at 21 shared 0x0000000103fbb09f _ZN6Worker19processQueueElementEb + 3135
at 22 shared 0x0000000103fba446 _ZN12_GLOBAL__N_113workerRoutineEPv + 54
at 23 libsystem_pthread.dylib 0x00007fff524602eb _pthread_body + 126
at 24 libsystem_pthread.dylib 0x00007fff52463249 _pthread_start + 66
at 25 libsystem_pthread.dylib 0x00007fff5245f40d thread_start + 13
(lldb)
This is what my implementation looks like
fun postRequest() {
MainScope().launch {
withContext(Dispatchers.Default) {
HttpClient().post("URL"){
body = "some json"
}
}
}
}
This request is working fine for the Android application and only throws the exception in iOS. Also if I try to run HttpClient().post on the main thread, it works fine on iOS and I am successfully able to send the request.
ktorVersion = "1.4.2"
coroutinesVersion = "1.3.9-native-mt-2"John O'Reilly
11/11/2020, 8:03 AMe5l
11/11/2020, 4:51 PMThomas
11/11/2020, 6:13 PM@SharedImmutable
.e5l
11/11/2020, 7:10 PM1.4.3
Amritansh
11/11/2020, 8:09 PMThomas
11/11/2020, 8:31 PMmavenLocal()
to your project as well (above all other repositories)Amritansh
11/11/2020, 9:59 PMio.ktor.tests.server.jetty.http2.JettyHttp2AsyncServletContainerSustainabilityTest[jvm] > testBigFile[jvm] FAILED
org.junit.runners.model.TestTimedOutException at Unsafe.java:-2
io.ktor.client.tests.MultithreadedTest[jvm] > numberTest[OkHttp][jvm] FAILED
org.junit.runners.model.TestTimedOutException at MultithreadedTest.kt:19
fix_incorrectdereferenceexception
Exception in thread "main" java.lang.Error: /var/folders/pc/f99yxpjj3tg1pwzdyx8jlwxcsjs57v/T/tmp8949358749675910999.c:1:10: fatal error: 'curl.h' file not found
at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:152)
at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.indexDeclarations(Indexer.kt:1003)
at org.jetbrains.kotlin.native.interop.indexer.IndexerKt.buildNativeIndexImpl(Indexer.kt:992)
at org.jetbrains.kotlin.native.interop.indexer.NativeIndexKt.buildNativeIndex(NativeIndex.kt:91)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:266)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:72)
at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:45)
at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:19)
at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:37)
> Task :ktor-client:ktor-client-curl:cinteropLibcurlMacosX64 FAILED
Thomas
11/11/2020, 10:21 PM@Ignore
to every test that is failing, that should work I thinkAmritansh
11/11/2020, 11:16 PM