napperley
06/11/2022, 2:21 AMCPointer
that points to the end of a CArrayPointer
as a parameter to a C function? Below is what I have so far:
private val globalArena = Arena()
// Use 65 KB for the stack size.
private const val STACK_SIZE = 65536
private val stack = globalArena.allocArray<ByteVar>(STACK_SIZE)
// ...
fun main() {
println("Hello from Parent!")
clone_process(fn = staticCFunction(::runContainer), stack = stack + STACK_SIZE, flags = SIGCHLD, arg = null)
// ...
}
// ...
Running the program results in a segmentation fault occurring after calling the clone_process function.napperley
06/11/2022, 2:43 AMCPointer
that points to the end of a CArrayPointer
?Dominaezzz
06/11/2022, 5:37 AMLandry Norris
06/11/2022, 7:14 PMLandry Norris
06/11/2022, 7:17 PMnapperley
06/11/2022, 10:00 PMCArrayPointer
?Landry Norris
06/11/2022, 10:52 PMDominaezzz
06/11/2022, 11:14 PMCPointer<ByteVar>
napperley
06/11/2022, 11:18 PMclone_process(
fn = staticCFunction(::runContainer),
stack = stack + (STACK_SIZE - 1),
flags = SIGCHLD,
arg = null
)
With this line stack + (STACK_SIZE - 1)
the type is CArrayPointer<ByteVar>
, which is the same type stack uses. Below is the output from the program:
Hello from Parent!
Hello from Child!
napperley
06/11/2022, 11:20 PMstack + STACK_SIZE
Landry Norris
06/12/2022, 1:08 AMnapperley
06/12/2022, 1:45 AM