Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
infinite recursion
#1
Bug 
In python version 3.13....
I noticed the possibility of creating infinite recursion, that is, the stack does not overflow, this could be attributed to optimizing the "tail" recursion, but memory measurements showed that memory is consumed until it runs out.
Here is the code for reproducing such a recursion:
def foo(depth=None):
    print(foo.count)
    foo.count += 1
    return foo()


foo.count = 1
print(foo())
It is noteworthy that if you remove the default argument, or run this code on version 3.11..., the stack overflow error will cause
Larz60+ write Apr-19-2025, 04:34 PM:
Please do not make duplicate threads. It is against forum rules.
Please read: Posts to NOT make at all
Have (soft) deleted two threads.
Reply
#2
sorry, I didn't do it on purpose, thank you
Reply
#3
Multiple posts on infinite recursion is funny though.
jefsummers likes this post
Reply
#4
I tried the code in ubuntu and it does not reach maximum recursion depth. It sounds like a bug in Python 3.13. It is especially strange that there is no bug if you omit the depth=None argument.

It seemed that you already started a discussion in discuss.python.org but for some reason it disappeared allready.

I hope this will be addressed by Python core developers.

Why is this thread in the Homework forum? Did your teacher ask you to understand the bug?
« We can solve any problem by introducing an extra level of indirection »
Reply
#5
Python is my hobby, I am not a frequent guest on forums, if I made a mistake in the forum section - forgive me and direct me, yes I made a similar post on Python core developers, but it was deleted...
only a post on the discussion forum remains....
I also hope that the developers will fix this bug
Reply
#6
I would assume that this bug is related to one of the optimizations of the function call
Reply
#7
the issue has been resolved, it's a bug, the kernel developers have taken the problem into development
Reply
#8
(Yesterday, 08:12 PM)Dimon Wrote: the kernel developers have taken the problem into development
Do you have a link to the issue?
« We can solve any problem by introducing an extra level of indirection »
Reply
#9
(Today, 05:15 AM)Gribouillis Wrote:
(Yesterday, 08:12 PM)Dimon Wrote: the kernel developers have taken the problem into development
Do you have a link to the issue?

https://github.com/python/cpython/issues/132744
from the form where I also started a discussion on this topic
https://discuss.python.org/t/infinite-re...n/88900/19
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020