I've managed to get K/N to segfault. How do I prin...
# kotlin-native
k
I've managed to get K/N to segfault. How do I print debug info to report this issue?
n
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
Yeah, gonna have to do some println. It literally just says
Segmentation fault (core dumped)
nothing else
n
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
I am using the new mm
on linuxx64
with ktor client and cURL
I (think) it's happening upon exit from
main
n
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
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