Skip to content

Commit c514b2c

Browse files
committed
Fixup
1 parent b8c019d commit c514b2c

File tree

7 files changed

+13
-4
lines changed

7 files changed

+13
-4
lines changed

Diff for: Zend/zend.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ void zend_startup(zend_utility_functions *utility_functions) /* {{{ */
10471047
EG(call_stack) = (zend_call_stack){0};
10481048
}
10491049
# endif /* ZEND_CHECK_STACK_LIMIT */
1050-
#endif
1050+
#endif /* ZTS */
10511051
EG(error_reporting) = E_ALL & ~E_NOTICE;
10521052

10531053
zend_interned_strings_init();

Diff for: Zend/zend_call_stack.h

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ static zend_always_inline void *zend_call_stack_position(void) {
4747

4848
static zend_always_inline bool zend_call_stack_overflowed(void *stack_limit) {
4949
return (uintptr_t) zend_call_stack_position() <= (uintptr_t) stack_limit;
50-
5150
}
5251

5352
static inline void* zend_call_stack_limit(void *base, size_t size, size_t reserved_size)

Diff for: Zend/zend_compile.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -10312,7 +10312,7 @@ static void zend_compile_expr_inner(znode *result, zend_ast *ast) /* {{{ */
1031210312
static void zend_compile_expr(znode *result, zend_ast *ast)
1031310313
{
1031410314
#ifdef ZEND_CHECK_STACK_LIMIT
10315-
if (zend_call_stack_overflowed(EG(stack_limit))) {
10315+
if (UNEXPECTED(zend_call_stack_overflowed(EG(stack_limit)))) {
1031610316
zend_error_noreturn(E_COMPILE_ERROR,
1031710317
"Maximum call stack size of %zu bytes reached. Try splitting expression",
1031810318
(size_t) ((uintptr_t) EG(stack_base) - (uintptr_t) EG(stack_limit)));

Diff for: Zend/zend_execute_API.c

+1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ void init_executor(void) /* {{{ */
178178
size_t size = EG(call_stack).max_size;
179179
if (UNEXPECTED(base == (void*)0)) {
180180
base = zend_call_stack_position();
181+
// TODO: account that base is not the real base
181182
size = zend_call_stack_default_size();
182183
}
183184
EG(stack_base) = base;

Diff for: Zend/zend_fibers.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,11 @@ ZEND_API void* zend_fiber_stack_limit(zend_fiber_stack *stack)
289289
/* stack->pointer is the end of the stack */
290290
return (int8_t*)stack->pointer + reserve;
291291
}
292+
293+
ZEND_API void* zend_fiber_stack_base(zend_fiber_stack *stack)
294+
{
295+
return (void*)((uintptr_t)stack->pointer + stack->size);
296+
}
292297
#endif
293298

294299
#ifdef ZEND_FIBER_UCONTEXT
@@ -526,7 +531,7 @@ static ZEND_STACK_ALIGNED void zend_fiber_execute(zend_fiber_transfer *transfer)
526531
EG(error_reporting) = error_reporting;
527532

528533
#ifdef ZEND_CHECK_STACK_LIMIT
529-
EG(stack_base) = (void*) ((uintptr_t) fiber->context.stack->pointer + fiber->context.stack->size);
534+
EG(stack_base) = zend_fiber_stack_base(fiber->context.stack);
530535
EG(stack_limit) = zend_fiber_stack_limit(fiber->context.stack);
531536
#endif
532537

Diff for: Zend/zend_fibers.h

+3
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,10 @@ struct _zend_fiber {
136136
ZEND_API bool zend_fiber_init_context(zend_fiber_context *context, void *kind, zend_fiber_coroutine coroutine, size_t stack_size);
137137
ZEND_API void zend_fiber_destroy_context(zend_fiber_context *context);
138138
ZEND_API void zend_fiber_switch_context(zend_fiber_transfer *transfer);
139+
#ifdef ZEND_CHECK_STACK_LIMIT
139140
ZEND_API void* zend_fiber_stack_limit(zend_fiber_stack *stack);
141+
ZEND_API void* zend_fiber_stack_base(zend_fiber_stack *stack);
142+
#endif /* ZEND_CHECK_STACK_LIMIT */
140143

141144
ZEND_API void zend_fiber_switch_block(void);
142145
ZEND_API void zend_fiber_switch_unblock(void);

Diff for: ext/zend_test/fiber.c

+1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ static ZEND_STACK_ALIGNED void zend_test_fiber_execute(zend_fiber_transfer *tran
9696
EG(jit_trace_num) = 0;
9797

9898
#ifdef ZEND_CHECK_STACK_LIMIT
99+
EG(stack_base) = zend_fiber_stack_base(fiber->context.stack);
99100
EG(stack_limit) = zend_fiber_stack_limit(fiber->context.stack);
100101
#endif
101102
fiber->fci.retval = &retval;

0 commit comments

Comments
 (0)