align stack for child process
authorRon Lockwood-Childs <rchilds@vctlabs.com>
Tue, 17 Oct 2017 09:22:58 +0000 (02:22 -0700)
committerRon Lockwood-Childs <rchilds@vctlabs.com>
Tue, 17 Oct 2017 09:22:58 +0000 (02:22 -0700)
Fixes "bus error" crashes on aarch64 caused by alignment faults.

On aarch64, the stack pointer needs to be 16-byte aligned; use gcc
builtin macro __BIGGEST_ALIGNMENT__ to specify a stack alignment
suitable for each platform.

subproc.c

index cc7b4af..942fc91 100644 (file)
--- a/subproc.c
+++ b/subproc.c
@@ -378,7 +378,7 @@ static bool subprocInitParent(struct nsjconf_t* nsjconf, pid_t pid, int pipefd)
 }
 
 /* Will be used inside the child process only, so it's save to have it in BSS */
-static uint8_t subprocCloneStack[128 * 1024]; /* 128 KiB */
+static uint8_t subprocCloneStack[128 * 1024] __attribute__(( aligned(__BIGGEST_ALIGNMENT__ ))); /* 128 KiB */
 /* Cannot be on the stack, as the child's stack pointer will change after clone() */
 static __thread jmp_buf env;