2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-28 21:07:43 +00:00

restore: Increase the stack size for cloned processes

Wasted a couple of hours trying to resolve this non-obvious
issue. It's because bootstrapping the restorer code might
requre more memory than 16K on stack. Strictly speaking
we need a compile time constant here and BUG_ON.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
This commit is contained in:
Cyrill Gorcunov 2011-11-07 22:58:18 +04:00
parent b78c664bca
commit 275e97c77d

View File

@ -1097,17 +1097,18 @@ static int do_child(void *arg)
static inline int fork_with_pid(int pid, char *pstree_path)
{
const int stack_size = 128 << 10;
int ret = 0;
void *stack;
stack = mmap(0, 4 * 4096, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON | MAP_GROWSDOWN, 0, 0);
stack = mmap(0, stack_size, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANON | MAP_GROWSDOWN, 0, 0);
if (stack == MAP_FAILED) {
pr_perror("mmap failed");
return -1;
}
stack += 4 * 4096;
stack += stack_size;
ret = clone(do_child, stack, SIGCHLD | CLONE_CHILD_USEPID, pstree_path, NULL, NULL, &pid);
if (ret < 0)
pr_perror("clone failed\n");