From 07b5a2a90cd2af846683960118639016287386d1 Mon Sep 17 00:00:00 2001 From: Ron Lockwood-Childs Date: Tue, 17 Oct 2017 02:22:58 -0700 Subject: [PATCH] align stack for child process 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 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subproc.c b/subproc.c index cc7b4af..942fc91 100644 --- 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;