Skip to content

Commit 1e7ae53

Browse files
committed
Fix typo and clarify
1 parent b28b230 commit 1e7ae53

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Python/ceval.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,12 +494,15 @@ hardware_stack_limits(uintptr_t *base, uintptr_t *top, uintptr_t sp)
494494
}
495495
# endif
496496
// Add some space for caller function then round to minimum page size
497+
// This is a guess at the top of the stack, but should be a reasonably
498+
// good guess if called from _PyThreadState_Attach when creating a thread.
499+
// If the thread is attached deep in a call stack, then the guess will be poor.
497500
#if _Py_STACK_GROWS_DOWN
498-
uintptr_t top_addr = _Py_SIZE_ROUND_UP(sp + 8*sizeof(void*), 4096);
501+
uintptr_t top_addr = _Py_SIZE_ROUND_UP(sp + 8*sizeof(void*), SYSTEM_PAGE_SIZE);
499502
*top = top_addr;
500503
*base = top_addr - Py_C_STACK_SIZE;
501504
# else
502-
uintptr_t base_addr = _Py_SIZE_ROUND_DOWN(sp - 8*sizeof(void*), 4096);
505+
uintptr_t base_addr = _Py_SIZE_ROUND_DOWN(sp - 8*sizeof(void*), SYSTEM_PAGE_SIZE);
503506
*base = base_addr;
504507
*top = base_addr + Py_C_STACK_SIZE;
505508
#endif
@@ -596,7 +599,7 @@ PyUnstable_ThreadState_ResetStackProtection(PyThreadState *tstate)
596599

597600

598601
/* The function _Py_EnterRecursiveCallTstate() only calls _Py_CheckRecursiveCall()
599-
if the stack poineter is between the stack base and c_stack_hard_limit. */
602+
if the stack pointer is between the stack base and c_stack_hard_limit. */
600603
int
601604
_Py_CheckRecursiveCall(PyThreadState *tstate, const char *where)
602605
{

0 commit comments

Comments
 (0)