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 @@ -451,6 +451,13 @@ _Py_InitializeRecursionLimits(PyThreadState *tstate)
451
451
SetThreadStackGuarantee (& guarantee );
452
452
_tstate -> c_stack_hard_limit = ((uintptr_t )low ) + guarantee + _PyOS_STACK_MARGIN_BYTES ;
453
453
_tstate -> c_stack_soft_limit = _tstate -> c_stack_hard_limit + _PyOS_STACK_MARGIN_BYTES ;
454
+ #elif defined(__APPLE__ )
455
+ pthread_t this_thread = pthread_self ();
456
+ void * stack_addr = pthread_get_stackaddr_np (this_thread ); // top of the stack
457
+ size_t stack_size = pthread_get_stacksize_np (this_thread );
458
+ _tstate -> c_stack_top = (uintptr_t )stack_addr ;
459
+ _tstate -> c_stack_hard_limit = _tstate -> c_stack_top - stack_size ;
460
+ _tstate -> c_stack_soft_limit = _tstate -> c_stack_hard_limit + _PyOS_STACK_MARGIN_BYTES ;
454
461
#else
455
462
uintptr_t here_addr = _Py_get_machine_stack_pointer ();
456
463
/// XXX musl supports HAVE_PTHRED_GETATTR_NP, but the resulting stack size
You can’t perform that action at this time.
0 commit comments