@@ -307,8 +307,7 @@ Py_SetRecursionLimit(int new_limit)
307307int
308308_Py_ReachedRecursionLimitWithMargin (PyThreadState * tstate , int margin_count )
309309{
310- char here ;
311- uintptr_t here_addr = (uintptr_t )& here ;
310+ uintptr_t here_addr = _Py_get_machine_stack_pointer ();
312311 _PyThreadStateImpl * _tstate = (_PyThreadStateImpl * )tstate ;
313312 if (here_addr > _tstate -> c_stack_soft_limit + margin_count * PYOS_STACK_MARGIN_BYTES ) {
314313 return 0 ;
@@ -322,8 +321,7 @@ _Py_ReachedRecursionLimitWithMargin(PyThreadState *tstate, int margin_count)
322321void
323322_Py_EnterRecursiveCallUnchecked (PyThreadState * tstate )
324323{
325- char here ;
326- uintptr_t here_addr = (uintptr_t )& here ;
324+ uintptr_t here_addr = _Py_get_machine_stack_pointer ();
327325 _PyThreadStateImpl * _tstate = (_PyThreadStateImpl * )tstate ;
328326 if (here_addr < _tstate -> c_stack_hard_limit ) {
329327 Py_FatalError ("Unchecked stack overflow." );
@@ -360,8 +358,7 @@ _Py_InitializeRecursionLimits(PyThreadState *tstate)
360358 _tstate -> c_stack_hard_limit = ((uintptr_t )low ) + guarantee + PYOS_STACK_MARGIN_BYTES ;
361359 _tstate -> c_stack_soft_limit = _tstate -> c_stack_hard_limit + PYOS_STACK_MARGIN_BYTES ;
362360#else
363- char here ;
364- uintptr_t here_addr = (uintptr_t )& here ;
361+ uintptr_t here_addr = _Py_get_machine_stack_pointer ();
365362# if defined(HAVE_PTHREAD_GETATTR_NP )
366363 size_t stack_size , guard_size ;
367364 void * stack_addr ;
392389_Py_CheckRecursiveCall (PyThreadState * tstate , const char * where )
393390{
394391 _PyThreadStateImpl * _tstate = (_PyThreadStateImpl * )tstate ;
395- char here ;
396- uintptr_t here_addr = (uintptr_t )& here ;
392+ uintptr_t here_addr = _Py_get_machine_stack_pointer ();
397393 assert (_tstate -> c_stack_soft_limit != 0 );
398394 if (_tstate -> c_stack_hard_limit == 0 ) {
399395 _Py_InitializeRecursionLimits (tstate );
0 commit comments