Skip to content

infinite loop in PyRun_InteractiveLoopFlags() #74881

Closed

Description

@xdegaye
mannequin
BPO 30696
Nosy @vstinner, @xdegaye
PRs
  • bpo-30696: Fix the REPL looping endlessly when no memory #4160
  • [3.6] bpo-30696: Fix the REPL looping endlessly when no memory (GH-41… #4379
  • Files
  • infinite_loop.patch
  • 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 2017-11-12.16:33:59.948>
    created_at = <Date 2017-06-18.10:33:04.834>
    labels = ['interpreter-core', 'type-bug', '3.7']
    title = 'infinite loop in PyRun_InteractiveLoopFlags()'
    updated_at = <Date 2017-11-13.12:40:12.021>
    user = 'https://github.com/xdegaye'

    bugs.python.org fields:

    activity = <Date 2017-11-13.12:40:12.021>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-11-12.16:33:59.948>
    closer = 'xdegaye'
    components = ['Interpreter Core']
    creation = <Date 2017-06-18.10:33:04.834>
    creator = 'xdegaye'
    dependencies = []
    files = ['46959']
    hgrepos = []
    issue_num = 30696
    keywords = ['patch']
    message_count = 9.0
    messages = ['296267', '296322', '296324', '306118', '306120', '306151', '306152', '306153', '306155']
    nosy_count = 2.0
    nosy_names = ['vstinner', 'xdegaye']
    pr_nums = ['4160', '4379']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue30696'
    versions = ['Python 3.6', 'Python 3.7']

    Activity

    1. xdegaye commented on Jun 18, 2017

      xdegayemannequin
      MannequinAuthor
      To reproduce the problem, apply the nomemory_allocator.patch from issue 30695 and run the following two statements that must be interrupted with ^C:
      $  ./python -q
      >>> import _testcapi
      >>> _testcapi.set_nomemory_allocator()
      sys.excepthook is missing
      ^Cpython: Objects/call.c:785: PyEval_CallObjectWithKeywords: Assertion `!PyErr_Occurred()' failed.
      Aborted (core dumped)

      The attached patch fixes this problem.
      No PR for the moment: this patch and nomemory_allocator.patch are needed to demonstrate other issues.

    2. added
      interpreter-core(Objects, Python, Grammar, and Parser dirs)
      type-bugAn unexpected behavior, bug, or error
      on Jun 18, 2017
    3. xdegaye commented on Jun 19, 2017

      xdegayemannequin
      MannequinAuthor

      The patch is far too simplistic. With this patch an exception kills the interactive loop, for example:

      $ ./python -q
      >>> x
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      NameError: name 'x' is not defined
      $
    4. vstinner commented on Jun 19, 2017

      @vstinner
      Member

      See also my old issue bpo-8070 opened 7 years ago :-)

    5. xdegaye commented on Nov 12, 2017

      xdegayemannequin
      MannequinAuthor

      New changeset e0582a3 by xdegaye in branch 'master':
      bpo-30696: Fix the REPL looping endlessly when no memory (GH-4160)
      e0582a3

    6. xdegaye commented on Nov 12, 2017

      xdegayemannequin
      MannequinAuthor

      New changeset ea5b545 by xdegaye in branch '3.6':
      [3.6] bpo-30696: Fix the REPL looping endlessly when no memory (GH-4160). (bpo-4379)
      ea5b545

    7. vstinner commented on Nov 13, 2017

      @vstinner
      Member

      Thanks for fixing this very old bug!

      What about Python 2.7?

    8. xdegaye commented on Nov 13, 2017

      xdegayemannequin
      MannequinAuthor

      What about Python 2.7?

      _testcapi.set_nomemory() does not exist on Pyhton 2.7 so the changes cannot be tested. Applying the changes to PyRun_InteractiveLoopFlags() in 2.7 looks rather straightforward but there are too many differences in PyRun_InteractiveOneFlags() between 2.7 and 3.7.

    9. xdegaye commented on Nov 13, 2017

      xdegayemannequin
      MannequinAuthor

      Also the existing test coverage of these functions in all the Python versions is very weak.

    10. vstinner commented on Nov 13, 2017

      @vstinner
      Member

      Ok, I understand, thanks for the explanation.

    11. 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

      3.7 (EOL)end of lifeinterpreter-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