File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -437,6 +437,13 @@ _Py_InitializeRecursionLimits(PyThreadState *tstate)
437437 SetThreadStackGuarantee (& guarantee );
438438 _tstate -> c_stack_hard_limit = ((uintptr_t )low ) + guarantee + _PyOS_STACK_MARGIN_BYTES ;
439439 _tstate -> c_stack_soft_limit = _tstate -> c_stack_hard_limit + _PyOS_STACK_MARGIN_BYTES ;
440+ #elif defined(__APPLE__ )
441+ pthread_t this_thread = pthread_self ();
442+ void * stack_addr = pthread_get_stackaddr_np (this_thread ); // top of the stack
443+ size_t stack_size = pthread_get_stacksize_np (this_thread );
444+ _tstate -> c_stack_top = (uintptr_t )stack_addr ;
445+ _tstate -> c_stack_hard_limit = _tstate -> c_stack_top - stack_size ;
446+ _tstate -> c_stack_soft_limit = _tstate -> c_stack_hard_limit + _PyOS_STACK_MARGIN_BYTES ;
440447#else
441448 uintptr_t here_addr = _Py_get_machine_stack_pointer ();
442449/// XXX musl supports HAVE_PTHRED_GETATTR_NP, but the resulting stack size
You can’t perform that action at this time.
0 commit comments