Skip to content

Commit be99bd4

Browse files
committed
Account for trace buffer as well
1 parent 0a889df commit be99bd4

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Python/optimizer.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,12 @@ _PyOptimizer_Optimize(
114114
_PyInterpreterFrame *frame, _Py_CODEUNIT *start,
115115
_PyExecutorObject **executor_ptr, int chain_depth)
116116
{
117+
/* Make sure we have enough C stack space for the buffer */
118+
int margin = 1 + sizeof(_PyUOpInstruction) * UOP_MAX_TRACE_LENGTH / _PyOS_STACK_MARGIN_BYTES;
119+
if (_Py_ReachedRecursionLimitWithMargin(_PyThreadState_GET(), margin)) {
120+
return 0;
121+
}
122+
117123
_PyStackRef *stack_pointer = frame->stackpointer;
118124
assert(_PyInterpreterState_GET()->jit);
119125
// The first executor in a chain and the MAX_CHAIN_DEPTH'th executor *must*

0 commit comments

Comments
 (0)