Skip to content

sys.setrecursionlimit(2**30) breaks interactive shell #63297

Closed

Description

@Arfrever
mannequin
BPO 19098

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2013-09-27.02:22:13.971>
created_at = <Date 2013-09-27.01:44:24.122>
labels = ['interpreter-core']
title = 'sys.setrecursionlimit(2**30) breaks interactive shell'
updated_at = <Date 2013-09-27.02:22:13.943>
user = 'https://bugs.python.org/Arfrever'

bugs.python.org fields:

activity = <Date 2013-09-27.02:22:13.943>
actor = 'python-dev'
assignee = 'none'
closed = True
closed_date = <Date 2013-09-27.02:22:13.971>
closer = 'python-dev'
components = ['Interpreter Core']
creation = <Date 2013-09-27.01:44:24.122>
creator = 'Arfrever'
dependencies = []
files = []
hgrepos = []
issue_num = 19098
keywords = ['3.3regression']
message_count = 2.0
messages = ['198460', '198461']
nosy_count = 2.0
nosy_names = ['Arfrever', 'python-dev']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue19098'
versions = ['Python 3.3', 'Python 3.4']

Activity

  1. Arfrever commented on Sep 27, 2013

    Arfrevermannequin
    MannequinAuthor

    sys.setrecursionlimit(2**30) breaks interactive shell in Python >=3.3.
    This bug does not occur during non-interactive execution of scripts / modules.
    This bug does not occur in versions of Python older than 3.3.

    This bug occurs only for some range of values of recursion limit. There are higher values, which do not cause this bug.
    sys.setrecursionlimit(2**31), as expected, raises OverflowError.
    Values like 2**31-1 (i.e. 2147483647) cause no problem:

    $ python3.4 -q
    >>> import sys
    >>> sys.setrecursionlimit(2**31)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    OverflowError: signed integer is greater than maximum
    >>> sys.setrecursionlimit(2**31-1)
    >>> sys.getrecursionlimit()
    2147483647
    >>> 0
    0
    >>> 

    Lower limit of values of recursion limit, which cause this bug: 715827883 == 2**29 + 2**27 + 2**25 + 2**23 + 2**21 + 2**19 + 2**17 + 2**15 + 2**13 + 2**11 + 2**9 + 2**7 + 2**5 + 2**3 + 2**1 + 1
    Upper limit of values of recursion limit, which cause this bug: 1431655765 == 2**30 + 2**28 + 2**26 + 2**24 + 2**22 + 2**20 + 2**18 + 2**16 + 2**14 + 2**12 + 2**10 + 2**8 + 2**6 + 2**4 + 2**2 + 1

    Example of this bug:

    $ python3.4 -q
    >>> import sys
    >>> sys.setrecursionlimit(2**30)
    >>> 0
    RuntimeError: maximum recursion depth exceeded during compilation
    >>> "a"
    RuntimeError: maximum recursion depth exceeded during compilation
    >>> 
    RuntimeError: maximum recursion depth exceeded during compilation
    >>>

    RuntimeError occurs for each line (even empty). Ctrl+D still works.

    I use 64-bit GNU/Linux.

  2. python-dev commented on Sep 27, 2013

    python-devmannequin
    Mannequin

    New changeset c3df31cbcd0a by Benjamin Peterson in branch '3.3':
    don't scale compiler stack frames if the recursion limit is huge (closes bpo-19098)
    http://hg.python.org/cpython/rev/c3df31cbcd0a

    New changeset 9a7ec433bf59 by Benjamin Peterson in branch 'default':
    merge 3.3 (bpo-19098)
    http://hg.python.org/cpython/rev/9a7ec433bf59

  3. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions