With a learning type project I am developing ( https://gitlab.com/napperley/containers ) it is partially based on this article: https://cesarvr.github.io/post/2018-05-22-create-containers/
There is a strange issue occurring where after running the Kotlin Native program a seg fault occurs in the child process, yet no seg fault occurs in the parent process. With the child process the seg fault seems to occur when calling a function from the POSIX library which is weird. Below is the function that represents the child process:
Copy code
@Suppress("UNUSED_PARAMETER")
private fun runContainer(args: COpaquePointer?): Int {
// Seg fault occurs on the line below.
println("Hello from Child! (PID: ${getpid()})")
// Remove all environment variables for this process.
clearenv()
// Load the shell process.
val rc = runProgram("/bin/sh")
return if (rc == -1) EXIT_FAILURE else EXIT_SUCCESS
}
napperley
06/12/2022, 10:30 PM
@Pavel Kunyavskiy [JB] - Has the Kotlin Native team done any testing with the experimental memory model in multi process use cases (using one of the Linux targets)?
p
Pavel Kunyavskiy [JB]
06/13/2022, 5:40 AM
Probably not. And I'm quite sure it wouldn't work out-of-box, as only calling thread is cloned to the new process, while others are not, and lots of internal machinery is totally unready for that, as for thread id changes.
Pavel Kunyavskiy [JB]
06/13/2022, 6:59 AM
Also, it seams you have a bug in runProgram function - it should add null as last array element. This could lead to interesting problems too.