diff --git a/sortix/x64/thread.cpp b/sortix/x64/thread.cpp index 85096a3f..671116ef 100644 --- a/sortix/x64/thread.cpp +++ b/sortix/x64/thread.cpp @@ -89,7 +89,8 @@ namespace Sortix // the entry function returns. Note that since we use a register based // calling convention, we call BootstrapKernelThread directly. regs->rip = (addr_t) BootstrapKernelThread; - regs->userrsp = stack + stacksize; + regs->userrsp = stack + stacksize - sizeof(size_t); + *((size_t*) regs->userrsp) = 0; /* back tracing stops at NULL rip */ regs->rax = 0; regs->rbx = 0; regs->rcx = 0; diff --git a/sortix/x86/thread.cpp b/sortix/x86/thread.cpp index 86306813..6ecf52de 100644 --- a/sortix/x86/thread.cpp +++ b/sortix/x86/thread.cpp @@ -76,7 +76,8 @@ namespace Sortix // calling convention, we go through a proxy that uses %edi and %esi // as parameters and pushes them to the stack and then does the call. regs->eip = (addr_t) asm_call_BootstrapKernelThread; - regs->useresp = stack + stacksize; + regs->useresp = stack + stacksize - sizeof(size_t); + *((size_t*) regs->useresp) = 0; /* back tracing stops at NULL rip */ regs->eax = 0; regs->ebx = 0; regs->ecx = 0;