Skip to content

Commit 31a83dc

Browse files
committed
Increase headroom
1 parent 7d6d77f commit 31a83dc

File tree

5 files changed

+4
-18
lines changed

5 files changed

+4
-18
lines changed

Include/internal/pycore_ceval.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ void _Py_unset_eval_breaker_bit_all(PyInterpreterState *interp, uintptr_t bit);
327327

328328
PyAPI_FUNC(PyObject *) _PyFloat_FromDouble_ConsumeInputs(_PyStackRef left, _PyStackRef right, double value);
329329

330+
extern int _PyOS_CheckStack(int words);
330331

331332
#ifdef __cplusplus
332333
}

Include/pythonrun.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ PyAPI_DATA(int) (*PyOS_InputHook)(void);
2323

2424
/* Stack size, in "pointers" (so we get extra safety margins
2525
on 64-bit platforms). On a 32-bit platform, this translates
26-
to an 8k margin. */
27-
#define PYOS_STACK_MARGIN 2048
26+
to an 16k margin. */
27+
#define PYOS_STACK_MARGIN 4096
2828
#define PYOS_STACK_MARGIN_BYTES (PYOS_STACK_MARGIN * sizeof(void *))
2929

3030
#if defined(WIN32) && !defined(MS_WIN64) && !defined(_M_ARM) && defined(_MSC_VER) && _MSC_VER >= 1300

Python/bytecodes.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,9 +1083,6 @@ dummy_func(
10831083
/* Restore previous frame and return. */
10841084
tstate->current_frame = frame->previous;
10851085
assert(!_PyErr_Occurred(tstate));
1086-
// PyEval_EvalDefault is a big function, so count it twice
1087-
_Py_LeaveRecursiveCallTstate(tstate);
1088-
_Py_LeaveRecursiveCallTstate(tstate);
10891086
PyObject *result = PyStackRef_AsPyObjectSteal(retval);
10901087
SYNC_SP(); /* Not strictly necessary, but prevents warnings */
10911088
return result;
@@ -5252,9 +5249,6 @@ dummy_func(
52525249
if (frame->owner == FRAME_OWNED_BY_INTERPRETER) {
52535250
/* Restore previous frame and exit */
52545251
tstate->current_frame = frame->previous;
5255-
// PyEval_EvalDefault is a big function, so count it twice
5256-
_Py_LeaveRecursiveCallTstate(tstate);
5257-
_Py_LeaveRecursiveCallTstate(tstate);
52585252
return NULL;
52595253
}
52605254
next_instr = frame->instr_ptr;

Python/ceval.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ _Py_InitializeRecursionCheck(PyThreadState *tstate)
326326
#ifdef USE_STACKCHECK
327327
if (_PyOS_CheckStack(PYOS_STACK_MARGIN * 2) == 0) {
328328
tstate->c_stack_soft_limit = here_addr - PYOS_STACK_MARGIN_BYTES;
329-
return 0;
329+
return;
330330
}
331331
int margin = PYOS_STACK_MARGIN;
332332
assert(tstate->c_stack_soft_limit != UINTPTR_MAX);
@@ -1033,9 +1033,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
10331033
assert(frame->owner == FRAME_OWNED_BY_INTERPRETER);
10341034
/* Restore previous frame and exit */
10351035
tstate->current_frame = frame->previous;
1036-
// PyEval_EvalDefault is a big function, so count it twice
1037-
_Py_LeaveRecursiveCallTstate(tstate);
1038-
_Py_LeaveRecursiveCallTstate(tstate);
10391036
return NULL;
10401037
}
10411038

Python/generated_cases.c.h

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)