X Tutup
The Wayback Machine - https://web.archive.org/web/20250523025246/https://github.com/python/cpython/issues/105003
Skip to content

stack overflow protection limit the max recursion depth when using custom frame evaluation #105003

Open
@art049

Description

@art049

Bug report

Enabling the perf trampoline messes with the recursion limit.

Reproduction

def recurse(n):
    if n == 0:
        return
    recurse(n - 1)


if __name__ == "__main__":
    import sys

    n = 801
    sys.setrecursionlimit(n)
    recurse(n - 2)

The following execution works perfectly:

python recurse.py

However, this gives a recursion error:

python -X perf recurse.py
Traceback (most recent call last):
  File "<...>/recurse.py", line 12, in <module>
    recurse(n - 2)
  File "<...>/recurse.py", line 4, in recurse
    recurse(n - 1)
  File "<...>/recurse.py", line 4, in recurse
    recurse(n - 1)
  File "<...>/recurse.py", line 4, in recurse
    recurse(n - 1)
  [Previous line repeated 796 more times]
RecursionError: maximum recursion depth exceeded

Strangely, the issue only arises when n >= 801 and not under this value.

@pablogsal if you have an idea of what could create the problem, I'd be happy to work on a fix!

Your environment

  • CPython versions tested on: 3.12.0b1, 3.12.0-dev(2c02c68)
  • OS: linux 5.15

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      X Tutup