8000 gh-117180: Complete call sequence when trace stack overflow (GH-117184) · python/cpython@6c83352 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6c83352

Browse files
Fidget-Spinnerlazorchakpgvanrossum
authored
gh-117180: Complete call sequence when trace stack overflow (GH-117184)
--------- Co-authored-by: Peter Lazorchak <lazorchakp@gmail.com> Co-authored-by: Guido van Rossum <gvanrossum@users.noreply.github.com> Co-authored-by: Guido van Rossum <gvanrossum@gmail.com>
1 parent f11d0d8 commit 6c83352

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

Lib/test/test_capi/test_opt.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,32 @@ def testfunc(n):
955955
_, ex = self._run_with_optimizer(testfunc, 16)
956956
self.assertIsNone(ex)
957957

958+
def test_many_nested(self):
959+
# overflow the trace_stack
960+
def dummy_a(x):
961+
return x
962+
def dummy_b(x):
963+
return dummy_a(x)
964+
def dummy_c(x):
965+
return dummy_b(x)
966+
def dummy_d(x):
967+
return dummy_c(x)
968+
def dummy_e(x):
969+
return dummy_d(x)
970+
def dummy_f(x):
971+
return dummy_e(x)
972+
def dummy_g(x):
973+
return dummy_f(x)
974+
def dummy_h(x):
975+
return dummy_g(x)
976+
def testfunc(n):
977+
a = 0
978+
for _ in range(n):
979+
a += dummy_h(n)
980+
return a
981+
982+
self._run_with_optimizer(testfunc, 32)
983+
958984

959985
if __name__ == "__main__":
960986
unittest.main()

Python/optimizer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,7 @@ BRANCH_TO_GUARD[4][2] = {
476476
if (trace_stack_depth >= TRACE_STACK_SIZE) { \
477477
DPRINTF(2, "Trace stack overflow\n"); \
478478
OPT_STAT_INC(trace_stack_overflow); \
479+
ADD_TO_TRACE(uop, oparg, operand, target); \
479480
ADD_TO_TRACE(_EXIT_TRACE, 0, 0, 0); \
480481
goto done; \
481482
} \

0 commit comments

Comments
 (0)
0