I am using version 1.3.50
# kotlin-native
p
I am using version 1.3.50
k
Maybe try running the test kexe directly on the command line. It’s in the build folder.
p
I’ve tried this but then I get a segmentation fault
kotlin.IllegalStateException: Cannot execute task because event loop was shut down
k
Yeah, that’s what’s happening
Do you see test progress output?
You can narrow down which test is crashing
p
Some tests are passing, some are failing. But then at some point there is a segmentation fault
Looks like the test is shut down
k
TaskTest.testTaskDelay
Copy code
[ RUN      ] com.nimmsta.sharedapi.promise.TaskTest.testTaskDelay
zsh: segmentation fault  ./test.kexe
It doesn’t finish
What’s that test doing?
You can pass an arg to the kexe so it’ll run specific tests:
--ktest_regex_filter=.*$1.*
Replace $1 with testTaskDelay, so like
--ktest_regex_filter=.*testTaskDelay.*
p
That command says that it didn’t find any matches
k
Well, skip that I guess. Whatever is causing the seg fault happens in that test method
p
pat@Patricks-MacBook-Pro-2 debugTest % ./test.kexe --ktest_regex_filter=testTaskDelay [==========] Running 0 tests from 1 test cases. [----------] Global test environment set-up. [----------] 0 tests from com.nimmsta.sharedapi.promise.TaskTest [----------] 0 tests from com.nimmsta.sharedapi.promise.TaskTest (0 ms total) [----------] Global test environment tear-down [==========] 0 tests from 1 test cases ran. (0 ms total) [ PASSED ] 0 tests.
But should it cause a segmentation fault? Or is that a bug?
Seems like the test exe is just killed
k
What is that method doing? Should Kotlin native seg fault? Probably not, but it’ll depend what you’re doing
p
It starts a coroutine and delays for a couple of seconds, then awaits the result
k
Code?
p
But two other tests fail because the event loop was shut down
k
I assume you’re not trying to switch threads with the coroutine?
p
But I think you need the whole Task code
What task.sleep is doing is essentially calling delay(ms) and then await
k
What’s EmptyCoroutineContext?
p
Thats synonymous to not specifying one
k
So where does that code run?
What thread is what I’m getting at.
p
MacOS
I’m not sure
I haven’t really understood K/N concurrency model yet
k
Coroutines in native as of version 1.3.50 can’t pass data across threads
You absolutely need to understand the concurrency model
p
Yeah but other tests work
k
OK
p
Yes I know, I just started with this project
The idea is to port Kotlin JVM code to Windows
Dispatchers.Default doesn’t work
k
Yeah. You need to understand the concurrency model. This will be quite difficult if you don’t
For 1.3.50, you can’t use coroutines that run in different thread contexts. That will likely change in 1.3.60, assuming the library updates finish. I’m playing around with that now
p
Cool, thanks for the article
I will have a look
And thanks for your help
k
Good luck
p
I think I found the error
This is enough to result in a segmentation fault