Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Support sharing of coroutines across threads in Kotlin/Native #1648

Draft
wants to merge 3 commits into
base: develop
from

Conversation

@elizarov
Copy link
Member

elizarov commented Nov 7, 2019

Work in progress.

@elizarov elizarov changed the base branch from master to develop Nov 7, 2019
@elizarov elizarov force-pushed the native-mt branch from 7ca7a8a to 299eecd Nov 11, 2019
kotlin-native-sharing.md Outdated Show resolved Hide resolved
@elizarov elizarov force-pushed the native-mt branch 2 times, most recently from cc400ce to 9e975d8 Nov 16, 2019
kotlin-native-sharing.md Outdated Show resolved Hide resolved
@elizarov

This comment has been minimized.

Copy link
Member Author

elizarov commented Nov 20, 2019

I’ve published the first development preview version of multi-threaded kotlinx.coroutines version 1.3.2-native-mt-1 for Kotlin/Native (version 1.3.60) . Make sure to study the docs before using it:
https://github.com/Kotlin/kotlinx.coroutines/blob/native-mt/kotlin-native-sharing.md

@kpgalligan

This comment has been minimized.

Copy link

kpgalligan commented Nov 21, 2019

Itr in AbstractChannel has been frozen in some of our cases and throwing immutability exceptions: https://github.com/Kotlin/kotlinx.coroutines/blob/native-mt/kotlinx-coroutines-core/common/src/channels/AbstractChannel.kt#L824. Making result atomic seems to resolve issue, although I'm new to the code and have no idea of broader implications.

@elizarov

This comment has been minimized.

Copy link
Member Author

elizarov commented Nov 22, 2019

@kpgalligan

Itr in AbstractChannel has been frozen in some of our cases and throwing immutability exceptions

Thanks! Added test with reproducer and fixed.

@elizarov elizarov force-pushed the native-mt branch from ed5876e to cfcf704 Nov 25, 2019
@elizarov

This comment has been minimized.

Copy link
Member Author

elizarov commented Nov 25, 2019

I've squashed all the changes so far into a single commit making it easier to keep it rebased on top of the develop branch and, maybe, try to integrate some of the changes separately to minimize the size of this changeset.

@kpgalligan

This comment has been minimized.

Copy link

kpgalligan commented Nov 30, 2019

I've been running into an issue related to state freezing and coroutines. Essentially, if freezing fails inside the "machinery" of coroutines, we can get into a weird state. Here's a basic example.

    @Test
    fun freezeFail() = runBlockingTest {
        assertFails {
            returnState()
        }
    }

    suspend fun returnState() = withContext(stateDispatcher) {
        val sd = SomeData("arst")
        sd.ensureNeverFrozen()
        sd
    }

    data class SomeData(val s: String)

stateDispatcher is a newSingleThreadContext instance. The original use case is to create a mutable state thread that we can push/pull frozen state from. That works fine, but to guard the mutable state, I call ensureNeverFrozen() on it. The idea is that if the user tries to return the mutable state, it'll throw an exception rather than freeze.

I would expect an exception to be thrown from returnState(), but according to the exception message, "Fatal exception in coroutines machinery ...", the fail happens in a place that's not expected. The test exe "hangs" and needs to be killed.

For reference, this "works" as expected...

    suspend fun returnState() = withContext(stateDispatcher) {
        val sd = SomeData("arst")
        throw IllegalStateException("just testing")
//        sd.ensureNeverFrozen()
        sd
    }

The IllegalStateException is thrown, the test passes, and the exe completes.

There is an exception written to the console

Uncaught Kotlin exception: kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for DispatchedContinuation[WorkerCoroutineDispatcherImpl@5340a3d8, Continuation @ $returnState$lambda-3COROUTINE$4]. Please read KDoc to 'handleFatalException' method and report this incident to maintainers
        at 0   test.kexe                           0x0000000109f1b673 kfun:kotlin.Error.<init>(kotlin.String?;kotlin.Throwable?)kotlin.Error + 115 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/Exceptions.kt:14:63)
        at 1   test.kexe                           0x000000010a024bb3 kfun:kotlinx.coroutines.CoroutinesInternalError.<init>(kotlin.String;kotlin.Throwable)kotlinx.coroutines.CoroutinesInternalError + 115 (/Users/kgalligan/temp/kotlinx.coroutines/kotlinx-coroutines-core/common/src/Exceptions.common.kt:28:77)
        at 2   test.kexe                           0x000000010a044c7d kfun:kotlinx.coroutines.DispatchedTask.handleFatalException$kotlinx-coroutines-core(kotlin.Throwable?;kotlin.Throwable?) + 925 (/Users/kgalligan/temp/kotlinx.coroutines/kotlinx-coroutines-core/common/src/internal/DispatchedTask.kt:93:22)
        at 3   test.kexe                           0x000000010a044877 kfun:kotlinx.coroutines.DispatchedTask.run() + 3559 (/Users/kgalligan/temp/kotlinx.coroutines/kotlinx-coroutines-core/common/src/internal/DispatchedTask.kt:64:13)
        at 4   test.kexe                           0x000000010a01fdef kfun:kotlinx.coroutines.EventLoopImplBase.processNextEvent()ValueType + 783 (/Users/kgalligan/temp/kotlinx.coroutines/kotlinx-coroutines-core/common/src/EventLoop.common.kt:271:20)
        at 5   test.kexe                           0x000000010a057f75 kfun:kotlinx.coroutines.runEventLoop$kotlinx-coroutines-core(kotlinx.coroutines.EventLoop?;kotlin.Function0<kotlin.Boolean>) + 869 (/Users/kgalligan/temp/kotlinx.coroutines/kotlinx-coroutines-core/native/src/Builders.kt:80:40)
        at 6   test.kexe                           0x000000010a060842 kfun:kotlinx.coroutines.WorkerCoroutineDispatcherImpl.start$lambda-0#internal + 402 (/Users/kgalligan/temp/kotlinx.coroutines/kotlinx-coroutines-core/native/src/Workers.kt:48:0)
        at 7   test.kexe                           0x000000010a060a2b kfun:kotlinx.coroutines.WorkerCoroutineDispatcherImpl.$start$lambda-0$FUNCTION_REFERENCE$15.invoke#internal + 59 (/Users/kgalligan/temp/kotlinx.coroutines/kotlinx-coroutines-core/native/src/Workers.kt:47:24)
        at 8   test.kexe                           0x000000010a060a8b kfun:kotlinx.coroutines.WorkerCoroutineDispatcherImpl.$start$lambda-0$FUNCTION_REFERENCE$15.$<bridge-UNN>invoke()#internal + 59 (/Users/kgalligan/temp/kotlinx.coroutines/kotlinx-coroutines-core/native/src/Workers.kt:47:24)
        at 9   test.kexe                           0x0000000109f4d701 WorkerLaunchpad + 177 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt:66:54)
        at 10  test.kexe                           0x000000010a0b8bf9 _ZN6Worker19processQueueElementEb + 2569
        at 11  test.kexe                           0x000000010a0b91a6 _ZN12_GLOBAL__N_113workerRoutineEPv + 54
        at 12  libsystem_pthread.dylib             0x00007fff67fe42eb _pthread_body + 126
        at 13  libsystem_pthread.dylib             0x00007fff67fe7249 _pthread_start + 66
        at 14  libsystem_pthread.dylib             0x00007fff67fe340d thread_start + 13
Caused by: kotlin.native.concurrent.FreezingException: freezing of SomeData(s=arst) has failed, first blocker is SomeData(s=arst)
        at 0   test.kexe                           0x0000000109f21387 kfun:kotlin.Throwable.<init>(kotlin.String?)kotlin.Throwable + 87 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/Throwable.kt:22:37)
        at 1   test.kexe                           0x0000000109f1b095 kfun:kotlin.Exception.<init>(kotlin.String?)kotlin.Exception + 85 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/Exceptions.kt:23:44)
        at 2   test.kexe                           0x0000000109f1acf5 kfun:kotlin.RuntimeException.<init>(kotlin.String?)kotlin.RuntimeException + 85 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/Exceptions.kt:34:44)
        at 3   test.kexe                           0x0000000109f4c2b1 kfun:kotlin.native.concurrent.FreezingException.<init>(kotlin.Any;kotlin.Any)kotlin.native.concurrent.FreezingException + 641 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/native/concurrent/Freezing.kt:15:9)
        at 4   test.kexe                           0x0000000109f4d84e ThrowFreezingException + 222 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt:84:15)
        at 5   test.kexe                           0x000000010a0a507b FreezeSubgraph + 2635
        at 6   test.kexe                           0x000000010a0bd03b Kotlin_Worker_freezeInternal + 27
        at 7   test.kexe                           0x0000000109f4bf9b kfun:kotlin.native.concurrent.freeze@#GENERIC.()Generic + 59 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/native/concurrent/Freezing.kt:33:5)
        at 8   test.kexe                           0x000000010a0282be kfun:kotlinx.coroutines.JobSupport.tryFinalizeSimpleState#internal + 1326 (/opt/buildAgent/work/88b0986a7186d029/atomicfu/src/nativeMain/kotlin/kotlinx/atomicfu/AtomicFU.kt:37:32)
        at 9   test.kexe                           0x000000010a032975 kfun:kotlinx.coroutines.JobSupport.tryMakeCompleting#internal + 805 (/Users/kgalligan/temp/kotlinx.coroutines/kotlinx-coroutines-core/common/src/JobSupport.kt:859:17)
        at 10  test.kexe                           0x000000010a03232e kfun:kotlinx.coroutines.JobSupport.makeCompletingOnce$kotlinx-coroutines-core(kotlin.Any?)kotlin.Any? + 590 (/Users/kgalligan/temp/kotlinx.coroutines/kotlinx-coroutines-core/common/src/JobSupport.kt:177:0)
        at 11  test.kexe                           0x000000010a00e6e4 kfun:kotlinx.coroutines.AbstractCoroutine.resumeWith(kotlin.Result<#GENERIC>) + 292 (/Users/kgalligan/temp/kotlinx.coroutines/kotlinx-coroutines-core/common/src/AbstractCoroutine.kt:111:21)
        at 12  test.kexe                           0x0000000109f416cc kfun:kotlin.coroutines.native.internal.BaseContinuationImpl.resumeWith(kotlin.Result<kotlin.Any?>) + 1420 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/coroutines/ContinuationImpl.kt:26:0)
        at 13  test.kexe                           0x000000010a044563 kfun:kotlinx.coroutines.DispatchedTask.run() + 2771 (/Users/kgalligan/temp/kotlinx.coroutines/kotlinx-coroutines-core/common/src/internal/DispatchedTask.kt:42:0)
        at 14  test.kexe                           0x000000010a01fdef kfun:kotlinx.coroutines.EventLoopImplBase.processNextEvent()ValueType + 783 (/Users/kgalligan/temp/kotlinx.coroutines/kotlinx-coroutines-core/common/src/EventLoop.common.kt:271:20)
        at 15  test.kexe                           0x000000010a057f75 kfun:kotlinx.coroutines.runEventLoop$kotlinx-coroutines-core(kotlinx.coroutines.EventLoop?;kotlin.Function0<kotlin.Boolean>) + 869 (/Users/kgalligan/temp/kotlinx.coroutines/kotlinx-coroutines-core/native/src/Builders.kt:80:40)
        at 16  test.kexe                           0x000000010a060842 kfun:kotlinx.coroutines.WorkerCoroutineDispatcherImpl.start$lambda-0#internal + 402 (/Users/kgalligan/temp/kotlinx.coroutines/kotlinx-coroutines-core/native/src/Workers.kt:48:0)
        at 17  test.kexe                           0x000000010a060a2b kfun:kotlinx.coroutines.WorkerCoroutineDispatcherImpl.$start$lambda-0$FUNCTION_REFERENCE$15.invoke#internal + 59 (/Users/kgalligan/temp/kotlinx.coroutines/kotlinx-coroutines-core/native/src/Workers.kt:47:24)
        at 18  test.kexe                           0x000000010a060a8b kfun:kotlinx.coroutines.WorkerCoroutineDispatcherImpl.$start$lambda-0$FUNCTION_REFERENCE$15.$<bridge-UNN>invoke()#internal + 59 (/Users/kgalligan/temp/kotlinx.coroutines/kotlinx-coroutines-core/native/src/Workers.kt:47:24)
        at 19  test.kexe                           0x0000000109f4d701 WorkerLaunchpad + 177 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt:66:54)
        at 20  test.kexe                           0x000000010a0b8bf9 _ZN6Worker19processQueueElementEb + 2569
        at 21  test.kexe                           0x000000010a0b91a6 _ZN12_GLOBAL__N_113workerRoutineEPv + 54
        at 22  libsystem_pthread.dylib             0x00007fff67fe42eb _pthread_body + 126
        at 23  libsystem_pthread.dylib             0x00007fff67fe7249 _pthread_start + 66
        at 24  libsystem_pthread.dylib             0x00007fff67fe340d thread_start + 13

kotlinx.coroutines is a local build that is up to 4aacce8

* Provides newSingleThreadedContext.
* Provides Dispatchers.Main on iOS, Dispatchers.Default everywhere.
* Coroutine references (Job) and all kinds of channels are shareable
  across workers.
* Each individual coroutine is confined to a single worker.

Known problems:
* There are some memory leaks in concurrent cases.
@elizarov elizarov force-pushed the native-mt branch from 4aacce8 to afe941e Dec 18, 2019
@kpgalligan

This comment has been minimized.

Copy link

kpgalligan commented Jan 14, 2020

It's been a while since there's been an update. I'm not sure if this will even be relevant now, but I've run into an issue where same-thread results are unfrozen until you run an operation on another thread and return a frozen result. From then on, using the same scope, same-thread operations return frozen results.

Presumably this is due to using FreezableAtomicReference for the result.

Here's a basic example:

fun goMain() = mainScope.launch {
    val result = withContext(Dispatchers.Main){
        SomeData2("236")
    }

    println("Main isFrozen ${result.isFrozen}")
}

fun goBackground() = mainScope.launch{
    val result = withContext(Dispatchers.Default){
        SomeData2("125")
    }

    println("Default isFrozen ${result.isFrozen}")
}

data class SomeData2(val s:String)

Two methods: goMain() and goBackground(). You can call goMain() multiple times and it'll print:

Main isFrozen false

When you call goBackground() it'll print that the result is frozen. Calling goMain() again, you'll get:

Main isFrozen true

This by itself isn't a huge issue, but it made ktor unusable with the same scope. As a workaround, we created 2 scopes, and reserve 1 for ktor only. Not ideal, but workable for now. I'm assuming the FreezableAtomicReference is in Job, as the other parts of the scope are the same between multiple scopes.

Our test scope here looks like this:

class ModelScope(private val mainContext: CoroutineContext) : CoroutineScope {
    internal val job = Job()
    private val exceptionHandler = CoroutineExceptionHandler { _, throwable ->
        println("error $throwable")
        throwable.printMe()
    }

    override val coroutineContext: CoroutineContext
        get() = mainContext + job + exceptionHandler
}

My expectation is that the same-thread behaviour would be consistent. Either always freeze or never freeze. I was surprised to have it act differently after calling another thread. Not sure how feasible that would be to implement, though.

Ktor was obviously not designed or tested to work with the MT preview version of coroutines, so it's not a huge surprise that we ran into issues.

@Thomas-Vos

This comment has been minimized.

Copy link

Thomas-Vos commented Jan 14, 2020

Hi, I am experiencing some issues with the Flow combine operator. The following code will throw an exception when running on Mac OS:

package sample

import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*
import kotlin.native.concurrent.*

fun main() {
    runBlocking {
        MyViewModel()
        delay(2000)
    }
}

class MyViewModel {
    val mainScope = CoroutineScope(Job() + Dispatchers.Default)

    init {
        ensureNeverFrozen()

        mainScope.launch {
            val flow = flowOf("string")
            combine(flow, flow) { a, b -> a to b }
                .collect {
                    println("this is never reached")
                }
        }
    }
}
Uncaught Kotlin exception: kotlinx.coroutines.CoroutinesInternalError: Fatal exception in coroutines machinery for DispatchedContinuation[WorkerCoroutineDispatcherImpl@53408588, Continuation @ $combineTransformInternal$lambda-0$<anonymous>_1_12COROUTINE$18]. Please read KDoc to 'handleFatalException' method and report this incident to maintainers
        at 0   KNConcurrencySamples.kexe           0x000000010c028943 kfun:kotlin.Error.<init>(kotlin.String?;kotlin.Throwable?)kotlin.Error + 115 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/Exceptions.kt:14:63)
        at 1   KNConcurrencySamples.kexe           0x000000010c08f1b3 kfun:kotlinx.coroutines.CoroutinesInternalError.<init>(kotlin.String;kotlin.Throwable)kotlinx.coroutines.CoroutinesInternalError + 115 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/Exceptions.common.kt:28:77)
        at 2   KNConcurrencySamples.kexe           0x000000010c0dd9bd kfun:kotlinx.coroutines.DispatchedTask.handleFatalException$kotlinx-coroutines-core(kotlin.Throwable?;kotlin.Throwable?) + 925 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/internal/DispatchedTask.kt:93:22)
        at 3   KNConcurrencySamples.kexe           0x000000010c0dd5b7 kfun:kotlinx.coroutines.DispatchedTask.run() + 3559 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/internal/DispatchedTask.kt:64:13)
        at 4   KNConcurrencySamples.kexe           0x000000010c08a3ef kfun:kotlinx.coroutines.EventLoopImplBase.processNextEvent()ValueType + 783 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/EventLoop.common.kt:272:20)
        at 5   KNConcurrencySamples.kexe           0x000000010c100445 kfun:kotlinx.coroutines.runEventLoop$kotlinx-coroutines-core(kotlinx.coroutines.EventLoop?;kotlin.Function0<kotlin.Boolean>) + 869 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/native/src/Builders.kt:80:40)
        at 6   KNConcurrencySamples.kexe           0x000000010c1078b2 kfun:kotlinx.coroutines.WorkerCoroutineDispatcherImpl.start$lambda-0#internal + 402 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/native/src/Workers.kt:48:0)
        at 7   KNConcurrencySamples.kexe           0x000000010c107a9b kfun:kotlinx.coroutines.WorkerCoroutineDispatcherImpl.$start$lambda-0$FUNCTION_REFERENCE$11.invoke#internal + 59 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/native/src/Workers.kt:47:24)
        at 8   KNConcurrencySamples.kexe           0x000000010c107afb kfun:kotlinx.coroutines.WorkerCoroutineDispatcherImpl.$start$lambda-0$FUNCTION_REFERENCE$11.$<bridge-UNN>invoke()#internal + 59 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/native/src/Workers.kt:47:24)
        at 9   KNConcurrencySamples.kexe           0x000000010c054211 WorkerLaunchpad + 177 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt:66:54)
        at 10  KNConcurrencySamples.kexe           0x000000010c158e59 _ZN6Worker19processQueueElementEb + 2569
        at 11  KNConcurrencySamples.kexe           0x000000010c159406 _ZN12_GLOBAL__N_113workerRoutineEPv + 54
        at 12  libsystem_pthread.dylib             0x00007fff73934e65 _pthread_start + 148
        at 13  libsystem_pthread.dylib             0x00007fff7393083b thread_start + 15
Caused by: kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen kotlinx.coroutines.flow.internal.$combineTransformInternal$lambda-0COROUTINE$21@53501d98
        at 0   KNConcurrencySamples.kexe           0x000000010c02e577 kfun:kotlin.Throwable.<init>(kotlin.String?)kotlin.Throwable + 87 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/Throwable.kt:22:37)
        at 1   KNConcurrencySamples.kexe           0x000000010c0283c5 kfun:kotlin.Exception.<init>(kotlin.String?)kotlin.Exception + 85 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/Exceptions.kt:23:44)
        at 2   KNConcurrencySamples.kexe           0x000000010c028025 kfun:kotlin.RuntimeException.<init>(kotlin.String?)kotlin.RuntimeException + 85 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/Exceptions.kt:34:44)
        at 3   KNConcurrencySamples.kexe           0x000000010c052e85 kfun:kotlin.native.concurrent.InvalidMutabilityException.<init>(kotlin.String)kotlin.native.concurrent.InvalidMutabilityException + 85 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/native/concurrent/Freezing.kt:22:60)
        at 4   KNConcurrencySamples.kexe           0x000000010c054648 ThrowInvalidMutabilityException + 680 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt:89:11)
        at 5   KNConcurrencySamples.kexe           0x000000010c151498 MutationCheck + 104
        at 6   KNConcurrencySamples.kexe           0x000000010c04cb70 kfun:kotlin.coroutines.native.internal.ContinuationImpl.<set-intercepted>#internal + 96 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/coroutines/ContinuationImpl.kt:98:13)
        at 7   KNConcurrencySamples.kexe           0x000000010c04d17c kfun:kotlin.coroutines.native.internal.ContinuationImpl.releaseIntercepted() + 428 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/coroutines/ContinuationImpl.kt:110:9)
        at 8   KNConcurrencySamples.kexe           0x000000010c04d926 kfun:kotlin.coroutines.native.internal.BaseContinuationImpl.resumeWith(kotlin.Result<kotlin.Any?>) + 1222 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/coroutines/ContinuationImpl.kt:26:0)
        at 9   KNConcurrencySamples.kexe           0x000000010c0ebc3f kfun:kotlinx.coroutines.selects.SelectBuilderImpl.resumeWith(kotlin.Result<#GENERIC>) + 2159 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/internal/DispatchedTask.kt:165:5)
        at 10  KNConcurrencySamples.kexe           0x000000010c04d9ec kfun:kotlin.coroutines.native.internal.BaseContinuationImpl.resumeWith(kotlin.Result<kotlin.Any?>) + 1420 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/coroutines/ContinuationImpl.kt:26:0)
        at 11  KNConcurrencySamples.kexe           0x000000010c0dd2a3 kfun:kotlinx.coroutines.DispatchedTask.run() + 2771 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/internal/DispatchedTask.kt:42:0)
        at 12  KNConcurrencySamples.kexe           0x000000010c08a3ef kfun:kotlinx.coroutines.EventLoopImplBase.processNextEvent()ValueType + 783 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/common/src/EventLoop.common.kt:272:20)
        at 13  KNConcurrencySamples.kexe           0x000000010c100445 kfun:kotlinx.coroutines.runEventLoop$kotlinx-coroutines-core(kotlinx.coroutines.EventLoop?;kotlin.Function0<kotlin.Boolean>) + 869 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/native/src/Builders.kt:80:40)
        at 14  KNConcurrencySamples.kexe           0x000000010c1078b2 kfun:kotlinx.coroutines.WorkerCoroutineDispatcherImpl.start$lambda-0#internal + 402 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/native/src/Workers.kt:48:0)
        at 15  KNConcurrencySamples.kexe           0x000000010c107a9b kfun:kotlinx.coroutines.WorkerCoroutineDispatcherImpl.$start$lambda-0$FUNCTION_REFERENCE$11.invoke#internal + 59 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/native/src/Workers.kt:47:24)
        at 16  KNConcurrencySamples.kexe           0x000000010c107afb kfun:kotlinx.coroutines.WorkerCoroutineDispatcherImpl.$start$lambda-0$FUNCTION_REFERENCE$11.$<bridge-UNN>invoke()#internal + 59 (/opt/buildAgent/work/44ec6e850d5c63f0/kotlinx-coroutines-core/native/src/Workers.kt:47:24)
        at 17  KNConcurrencySamples.kexe           0x000000010c054211 WorkerLaunchpad + 177 (/Users/teamcity3/buildAgent/work/4d622a065c544371/runtime/src/main/kotlin/kotlin/native/concurrent/Internal.kt:66:54)
        at 18  KNConcurrencySamples.kexe           0x000000010c158e59 _ZN6Worker19processQueueElementEb + 2569
        at 19  KNConcurrencySamples.kexe           0x000000010c159406 _ZN12_GLOBAL__N_113workerRoutineEPv + 54
        at 20  libsystem_pthread.dylib             0x00007fff73934e65 _pthread_start + 148
        at 21  libsystem_pthread.dylib             0x00007fff7393083b thread_start + 15

I don't think this is supposed to happen. It only happens with the combine operator for me, so I think that is the issue. The sample crashes for me with version 1.3.3-native-mt.

Trying to figure out #1745
@elizarov elizarov force-pushed the native-mt branch from e9ec4cb to 4a79ce7 Jan 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.