File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -360,6 +360,21 @@ _Py_InitializeRecursionLimits(PyThreadState *tstate)
360360 _tstate -> c_stack_hard_limit = ((uintptr_t )low ) + guarantee + PYOS_STACK_MARGIN_BYTES ;
361361 _tstate -> c_stack_soft_limit = _tstate -> c_stack_hard_limit + PYOS_STACK_MARGIN_BYTES ;
362362#else
363+ # if defined(_GNU_SOURCE )
364+ size_t stack_size , guard_size ;
365+ void * stack_addr ;
366+ pthread_attr_t attr ;
367+ int err = pthread_getattr_np (pthread_self (), & attr );
368+ err |= pthread_attr_getguardsize (& attr , & guard_size );
369+ err |= pthread_attr_getstack (& attr , & stack_addr , & stack_size );
370+ if (err == 0 ) {
371+ uintptr_t base = ((uintptr_t )stack_addr ) + guard_size ;
372+ _tstate -> c_stack_top = base + stack_size ;
373+ _tstate -> c_stack_soft_limit = base + PYOS_STACK_MARGIN_BYTES * 2 ;
374+ _tstate -> c_stack_hard_limit = base + PYOS_STACK_MARGIN_BYTES ;
375+ return ;
376+ }
377+ # endif
363378 char here ;
364379 uintptr_t here_addr = (uintptr_t )& here ;
365380 _tstate -> c_stack_top = _Py_SIZE_ROUND_UP (here_addr , 4096 );
You can’t perform that action at this time.
0 commit comments