Open
Description
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.pyHowever, this gives a recursion error:
python -X perf recurse.pyTraceback (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

