-/* $OpenBSD: rthread_stack.c,v 1.17 2017/09/05 02:40:54 guenther Exp $ */
+/* $OpenBSD: rthread_stack.c,v 1.18 2018/02/10 22:59:02 deraadt Exp $ */
/* PUBLIC DOMAIN: No Rights Reserved. Marco S Hyman <marc@snafu.org> */
#ifdef MACHINE_STACK_GROWS_UP
stack->sp = base + rnd;
#else
- stack->sp = base + thread->attr.stack_size - rnd;
+ stack->sp = base + thread->attr.stack_size - (_STACKALIGNBYTES+1) - rnd;
#endif
/*
* This impossible guardsize marks this stack as
stack->sp = base + rnd;
#else
guard = base;
- stack->sp = base + size - rnd;
+ stack->sp = base + size - (_STACKALIGNBYTES+1) - rnd;
#endif
/* memory protect the guard region */