From d9bb6da8119e1e7e1da2186dceaa1fe19c62c20c Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Thu, 21 Apr 2016 21:57:57 +0200 Subject: [PATCH] Fix pthread stack alignment. --- libc/pthread/pthread_create.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/libc/pthread/pthread_create.c b/libc/pthread/pthread_create.c index 42b9aec4..9a54f90a 100644 --- a/libc/pthread/pthread_create.c +++ b/libc/pthread/pthread_create.c @@ -81,15 +81,12 @@ static void setup_thread_state(struct pthread* thread, struct tfork* regs) (unsigned long*) ((uint8_t*) thread->uthread.stack_mmap + thread->uthread.stack_size); - *--stack = 0; // rip=0 - *--stack = 0; // rbp=0 - - regs->ebp = (uintptr_t) stack; - + *--stack = 0; // Alignment. *--stack = (unsigned long) thread; - *--stack = 0; + *--stack = 0; // rip=0 regs->esp = (uintptr_t) stack; + regs->ebp = 0; } #endif @@ -111,10 +108,9 @@ static void setup_thread_state(struct pthread* thread, struct tfork* regs) thread->uthread.stack_size); *--stack = 0; // rip=0 - *--stack = 0; // rbp=0 regs->rsp = (uintptr_t) stack; - regs->rbp = regs->rsp; + regs->rbp = 0; } #endif