https://kotlinlang.org logo
#kotlin-native
Title
# kotlin-native
k

kevin.cianfarini

08/23/2022, 2:04 AM
I've managed to get K/N to segfault. How do I print debug info to report this issue?
n

napperley

08/23/2022, 2:21 AM
What is causing the segfault (K/N library, C library, K/N runtime, some other third party library, or K/N program)?
Unfortunately Kotlin Native doesn't have any tools that provide detailed information on a segmentation fault that occurs in a K/N program. Depending on the K/N target there may be a tool available to provide this information (in a very generic way) like valgrind ( https://valgrind.org/ ) with the Linux targets for example. Keep in mind that if valgrind is used it isn't user friendly, and doesn't officially support Kotlin (can easily end up with confusing information which makes no sense).
One primitive option (if available) to consider is to pepper the K/N program with println calls, which will at least indicate where the segfault occurs in the program.
Do note that the Kotlin team don't provide a guide on how to use valgrind with a K/N program to get detailed memory usage information.
k

kevin.cianfarini

08/23/2022, 2:55 AM
Yeah, gonna have to do some println. It literally just says
Segmentation fault (core dumped)
nothing else
n

napperley

08/23/2022, 2:58 AM
I thought that would be the case with the very confusing error message (indicates some sort of general memory management issue). There are some other types of seg fault error messages, like the one covering floating point number errors.
@Pavel Punegov [JB] - Does K/N provide an option for a K/N program to generate a dump file (to diagnose memory management issues)?
k

kevin.cianfarini

08/23/2022, 3:05 AM
I am using the new mm
on linuxx64
with ktor client and cURL
I (think) it's happening upon exit from
main
n

napperley

08/23/2022, 4:21 AM
If it is occurring after exiting
main
(provided the program is exiting normally) then the issue is minor since the OS will automatically free all memory reserved by the program after it does a clean exit.
Have you tried using libcurl ( https://curl.se/libcurl/ ) instead of Ktor Client, and seeing what happens?
k

kevin.cianfarini

08/23/2022, 1:07 PM
I haven’t. I can try doing that. I was originally trying to use CIO but was getting an error message that TLS sessions aren’t supported on the native platform
This is for a quick and dirty project so I might have to revisit the use of ktor next week
3 Views