File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -328,15 +328,17 @@ _Py_CheckRecursiveCall(PyThreadState *tstate, const char *where)
328328 assert (tstate -> c_stack_soft_limit != 0 );
329329 if (tstate -> c_stack_hard_limit == 0 ) {
330330#ifdef USE_STACKCHECK
331- assert (_PyOS_CheckStack (PYOS_STACK_MARGIN ));
332331 if (_PyOS_CheckStack (PYOS_STACK_MARGIN * 2 ) == 0 ) {
333332 tstate -> c_stack_soft_limit = here_addr - PYOS_STACK_MARGIN_BYTES ;
334333 return 0 ;
335334 }
336- else {
337- assert (tstate -> c_stack_soft_limit != UINTPTR_MAX );
338- tstate -> c_stack_hard_limit = tstate -> c_stack_soft_limit - PYOS_STACK_MARGIN_BYTES ;
335+ assert (tstate -> c_stack_soft_limit != UINTPTR_MAX );
336+ int margin = PYOS_STACK_MARGIN * 3 /2 ;
337+ while (margin > 0 && _PyOS_CheckStack (margin )) {
338+ margin -= PYOS_STACK_MARGIN /2 ;
339339 }
340+ tstate -> c_stack_hard_limit = here_addr - margin * sizeof (void * );
341+ tstate -> c_stack_soft_limit = tstate -> c_stack_hard_limit + PYOS_STACK_MARGIN_BYTES ;
340342#else
341343 assert (tstate -> c_stack_soft_limit == UINTPTR_MAX );
342344 tstate -> c_stack_soft_limit = here_addr - Py_C_STACK_SIZE ;
You can’t perform that action at this time.
0 commit comments