4

My team uses Kotlin-Native to develop our iOS APP.

When a crash happend in kotlin, the crash call stack is not complete. But when I debug the app in XCode, the crash call stack is complete.

When I disconnect XCode and trigger the same crash in the app, and then connect to XCode the view crash log (XCode > Window > Devide and Simulator > view device logs), I find that one stack frame disappears, the red line in the image below:

the red line stack frame disappear in crash log

My team found out the 'objc2kotlin' function has a bug: The assembly code of objc2kotlin doesn't change the value of fp(frame pointer, x29) after pushing lr(link register, x30) and fp(frame pointer, x29).

Hope Kotlin-Native team fix the bug quickly, thank you very much.

shadowsheep
  • 14,048
  • 3
  • 67
  • 77
yuzhiyun
  • 41
  • 3
  • File an issue on github? https://github.com/JetBrains/kotlin-native/issues – Kevin Galligan Jan 25 '21 at 14:52
  • Please prefer filing issues on YouTrack: https://kotl.in/issue. Kotlin/Native issue tracking is migrating currently, see details [here](https://github.com/JetBrains/kotlin-native/issues/4079) – Artyom Degtyarev Jan 26 '21 at 07:54
  • @KevinGalligan My email is 2723364262@qq.com , can you contact with me by email,I can send you something more detail . – yuzhiyun Jan 26 '21 at 09:50
  • @ArtyomDegtyarev Due to network problem, I can not access YouTrack (I am in China), – yuzhiyun Jan 26 '21 at 09:50
  • @KevinGalligan here is my demo project. https://github.com/yuzhiyunAtTencent/KaMPKit, I only add some code to create a crash in this kotlin function (NativeViewModel.kt: updateBreedFavorite) , and I add some objc function to call "updateBreedFavorite", then launch the app, disconnect xcode, click heart button in the app, then connect xcode to view crash log, you can find that a stack frame before 'objc2kotlin' disappear! – yuzhiyun Jan 26 '21 at 10:09
  • The app of my company has more than ten million netizen, it's really a urgent situation for my team, because crash stack frame loss makes debug diffcult. I hope you can fix this bug, I really appreciate it!@KevinGalligan @ArtyomDegtyarev – yuzhiyun Jan 26 '21 at 10:41
  • Thank you very much for the report and the investigation, @yuzhiyun! I reproduced the problem, and shared it with the Kotlin/Native team. I will post an update here as soon as it will be available. Just for the record: The issue I've made for this bug is https://youtrack.jetbrains.com/issue/KT-44549 – Artyom Degtyarev Jan 26 '21 at 15:50
  • @ArtyomDegtyarev Nice! looking forward to your update – yuzhiyun Jan 27 '21 at 03:18
  • @ArtyomDegtyarev hello Is there any update recently ? – yuzhiyun Feb 01 '21 at 08:21
  • Hello, @yuzhiyun! The team agreed that you found the cause correctly. For now, the bugfix is scheduled for the 1.5 version. – Artyom Degtyarev Feb 01 '21 at 09:27
  • @ArtyomDegtyarev Wow! – yuzhiyun Feb 02 '21 at 02:36
  • @ArtyomDegtyarev Could you please tell me when kotlin 1.5 version will be availabel? – yuzhiyun Feb 02 '21 at 02:40
  • I got no details at the moment. One should expect it to be released somewhere in spring 2021(according to [this blog post](https://blog.jetbrains.com/kotlin/2020/10/new-release-cadence-for-kotlin-and-the-intellij-kotlin-plugin/)) – Artyom Degtyarev Feb 02 '21 at 08:22
  • @KevinGalligan @ ArtyomDegtyarev Hello, my leader asks me try to build a new kotlin version myself to fix this problem, can you tell me how to use my own kotlin in kampkit project(or other kotlin native project) – yuzhiyun Mar 17 '21 at 03:07
  • Hello, @yuzhiyun! As you can find in the README.md([here](https://github.com/JetBrains/kotlin/tree/master/kotlin-native)), after you build the compiler from sources, you should specify its location at the `gradle.properties` of your project. KampKit or any other. – Artyom Degtyarev Mar 17 '21 at 07:39
  • Thank you , In fact I follow the README yesterday, I install those jdks and then run "./gradlew :kotlin-native:dist :kotlin-native:distPlatformLibs" at master branch, it's built successful, next I add dist path to gradle.properties, at last,I run kampkit project in xcode, but this error occured : @ArtyomDegtyarev – yuzhiyun Mar 18 '21 at 03:16
  • > Task :shared:compileKotlinIos FAILED e: java.lang.NoSuchMethodError: org.jetbrains.kotlin.serialization.DescriptorSerializer$Companion.registerSerializerPlugin(Lorg/jetbrains/kotlin/serialization/DescriptorSerializerPlugin;)V at org.jetbrains.kotlinx.serialization.compiler.extensions.SerializationComponentRegistrar$Companion.registerProtoExtensions(SerializationComponentRegistrar.kt:48) – yuzhiyun Mar 18 '21 at 03:16
  • This error is probably caused by version mismatch between serialization compiler plugin (likely matches your Gradle plugin version) and K/N compiler. First, please note that you are building K/N from master branch, so it might be more unstable than 1.5.0-M*. The easiest way to try the fix now is to cherry-pick [the fix](https://github.com/JetBrains/kotlin-native/commit/c98c790bde1bde1df05f065c804b8e59a1316516) to the branch: https://github.com/JetBrains/kotlin-native/tree/v1.5.0-M1-fixes. Then build K/N from it and use it with Gradle plugin 1.5.0-M1. The fix will be included to 1.5.0-M2. – Svyatoslav Scherbina Mar 18 '21 at 07:02
  • @SvyatoslavScherbina Wow, thank you for the fix, could you tell me how you fix the stack missing bug, I look through the commit you ask me to cherry-pick, but I still can not understand why it's fixed. – yuzhiyun Mar 18 '21 at 09:44
  • I guess the function names "enforceFramePointer" makes frame pointer right, but what's the meaning of this function – yuzhiyun Mar 18 '21 at 10:01
  • Exactly. `enforceFramePointer` just instructs LLVM to use the frame pointer (i.e. update it in the prologue and the epilogue) for the function. – Svyatoslav Scherbina Mar 19 '21 at 10:42
  • I cherry-pickd and then tried to build my own K/N using this command (./gradlew dist distPlatformLibs) , finnaly use it in Kampkit project, but encounter this error, do you konw how to fix this error? Thanks a lot @SvyatoslavScherbina – yuzhiyun Mar 22 '21 at 09:31
  • w: skipping /Users/yuzhiyun/AndroidStudioProjects/kotlin-native/dist/klib/common/stdlib. The target doesn't match. Expected 'ios_arm64', found [macos_x64]e: Could not find "stdlib" – yuzhiyun Mar 22 '21 at 09:31
  • @yuzhiyun you've built K/N for macos_x64 target, but are trying to use it for ios_arm64 target. Please build support for ios_arm64 with `./gradlew ios_arm64PlatformLibs`. – Svyatoslav Scherbina Mar 23 '21 at 11:15
  • @ArtyomDegtyarev Hello, the spec.script_phases in my podspec looks like this: "../gradlew" :shared:syncFramework I wonder where I can find source code of "syncFramework", I want to learn deeper about KN, please show me the code about syncFramework, thank a lot – yuzhiyun Jun 02 '21 at 09:09
  • @KevinGalligan hello,please see this cinterop update problem. thank you !! https://stackoverflow.com/questions/67806811/kotlin-native-compilekotlinios-task-fails-beacuse-cinterop-task-can-not-update-w – yuzhiyun Jun 02 '21 at 14:10
  • @yuzhiyun the most appropriate place is, probably, the GitHub repo. Start with https://github.com/JetBrains/kotlin/search?q=syncFramework. – Artyom Degtyarev Jun 02 '21 at 17:22
  • @ArtyomDegtyarev Thank you for the 'syncFramework' link. Could you please see this cinterop update problem https://stackoverflow.com/questions/67806811/kotlin-native-compilekotlinios-task-fails-beacuse-cinterop-task-can-not-update-w – yuzhiyun Jun 03 '21 at 02:35

0 Answers0