Skip to content

Commit 209eacf

Browse files
committed
Increase SHSTK stack size
The shadow stack may need as much space as the fiber stack in the worse case, so allocate a shadow stack the same size as the fiber stack. This matches what the kernel does for the main stack.
1 parent d7a2119 commit 209eacf

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

Zend/zend_fibers.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,11 +266,7 @@ static zend_fiber_stack *zend_fiber_stack_allocate(size_t size)
266266
stack->size = stack_size;
267267

268268
#if !defined(ZEND_FIBER_UCONTEXT) && BOOST_CONTEXT_SHADOW_STACK
269-
/* shadow stack saves ret address only, need less space */
270-
stack->ss_size= stack_size >> 5;
271-
272-
/* align shadow stack to 8 bytes. */
273-
stack->ss_size = (stack->ss_size + 7) & ~7;
269+
stack->ss_size = stack_size;
274270

275271
/* issue syscall to create shadow stack for the new fcontext */
276272
/* SHADOW_STACK_SET_TOKEN option will put "restore token" on the new shadow stack */

0 commit comments

Comments
 (0)