Skip to content

Python 3 aborts with this code. #57853

Closed
Closed

Description

@RamchandraApte
BPO 13644
Nosy @birkenfeld, @terryjreedy, @benjaminp, @serwy
Superseder
  • bpo-6028: Interpreter aborts when chaining an infinite number of exceptions
  • 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 2011-12-24.22:45:47.412>
    created_at = <Date 2011-12-21.05:54:52.220>
    labels = ['interpreter-core', 'type-bug']
    title = 'Python 3 aborts with this code.'
    updated_at = <Date 2011-12-24.22:45:47.398>
    user = 'https://bugs.python.org/RamchandraApte'

    bugs.python.org fields:

    activity = <Date 2011-12-24.22:45:47.398>
    actor = 'terry.reedy'
    assignee = 'none'
    closed = True
    closed_date = <Date 2011-12-24.22:45:47.412>
    closer = 'terry.reedy'
    components = ['Interpreter Core']
    creation = <Date 2011-12-21.05:54:52.220>
    creator = 'Ramchandra Apte'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 13644
    keywords = []
    message_count = 19.0
    messages = ['149956', '149957', '149958', '149959', '150006', '150089', '150095', '150101', '150198', '150199', '150205', '150208', '150217', '150227', '150229', '150230', '150231', '150232', '150238']
    nosy_count = 5.0
    nosy_names = ['georg.brandl', 'terry.reedy', 'benjamin.peterson', 'roger.serwy', 'Ramchandra Apte']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = None
    status = 'closed'
    superseder = '6028'
    type = 'behavior'
    url = 'https://bugs.python.org/issue13644'
    versions = ['Python 3.2', 'Python 3.3']

    Activity

    1. RamchandraApte commented on Dec 21, 2011

      RamchandraAptemannequin
      MannequinAuthor

      When you run the following code, Python 3 (not Python 2) crashes.
      Interestingly, Python 2.7 doesn't seem to be affected and correctly raises an error about recursion ( so this must be a regression ).
      The code's recursion should be detected and Python should raise a RuntimeError about recursion.

      def recurse():
          try:raise Exception #An arbitary exception
          except Exception:recurse()

      After running this code Python 3 says "Fatal Python error: Cannot recover from stack overflow." and then Python aborts .
      In Jython, this code doesn't crash it.

    2. added
      type-crashA hard crash of the interpreter, possibly with a core dump
      interpreter-core(Objects, Python, Grammar, and Parser dirs)
      on Dec 21, 2011
    3. changed the title [-]Python crashes with this code.[/-] [+]Python 3 crashes with this code.[/+] on Dec 21, 2011
    4. changed the title [-]Python 3 crashes with this code.[/-] [+]Python 3 crashes (segfaults) with this code.[/+] on Dec 21, 2011
    5. benjaminp commented on Dec 21, 2011

      @benjaminp
      Contributor

      Python isn't crashing; it's bailing out of an impossible situation. It's not clear what the correct behavior is, since you're basically preventing Python from aborting the recursive behavior.

    6. RamchandraApte commented on Dec 21, 2011

      RamchandraAptemannequin
      MannequinAuthor

      But Python 2 doesn't crash after running the code.

    7. RamchandraApte commented on Dec 21, 2011

      RamchandraAptemannequin
      MannequinAuthor

      Oops, to reproduce this bug after running the code run "recurse()".

    8. benjaminp commented on Dec 21, 2011

      @benjaminp
      Contributor

      The behavior of Python 2 is not anymore correct than that of Python 3.

    9. RamchandraApte commented on Dec 22, 2011

      RamchandraAptemannequin
      MannequinAuthor

      Well, I expect Python 3 to raise RuntimeError about recursion not to segfault.

    10. benjaminp commented on Dec 22, 2011

      @benjaminp
      Contributor

      There is no place for it to raise a RuntimeError which will continue to propogate!

    11. serwy commented on Dec 22, 2011

      serwymannequin
      Mannequin

      With Python 2, I can inspect the error to see where it occurred using traceback. With Python 3, I'd need to use gdb.

    12. birkenfeld commented on Dec 23, 2011

      @birkenfeld
      Member

      @op: As you yourself wrote, this is an abort, not a segfault. It is not a crash; it is a controlled exit of the Python executable.

      @benjamin: I don't really understand your reasoning: what is preventing Python to raise the error during the except clause?

    13. changed the title [-]Python 3 crashes (segfaults) with this code.[/-] [+]Python 3 aborts with this code.[/+] on Dec 23, 2011
    14. benjaminp commented on Dec 23, 2011

      @benjaminp
      Contributor

      Nothing, but that would be pointless; the recursion would just start again.

    15. terryjreedy commented on Dec 24, 2011

      @terryjreedy
      Member

      When I run this with 3.2.2 IDLE, from an edit window, I get an MSVC++ Runtime Library window: "Runtime Error! .../pythonw This application has requested termination in an unusual way...". When I close that, IDLE continues. So I would say that this is not a crash and not even a bug, but a particular choice of undefined behavior given infinite loop code. So we have no obligation to change it. I presume the change from 2.x is a side-effect of a change to improve something else.

      def recurse(): recurse()
      recurse()

      does print "RuntimeError: maximum recursion depth exceeded" but only after printing a l o n g traceback. So for running from IDLE, I at least half prefer the immediate error box with no traceback.

    16. added
      type-bugAn unexpected behavior, bug, or error
      and removed
      type-crashA hard crash of the interpreter, possibly with a core dump
      on Dec 24, 2011
    17. RamchandraApte commented on Dec 24, 2011

      RamchandraAptemannequin
      MannequinAuthor

      @terry
      IDLE restarts python (like in the menu entry "Restart Shell") when the Python process dies no matter how the Python process dies.
      So this issue is a valid bug.

    18. serwy commented on Dec 24, 2011

      serwymannequin
      Mannequin

      This is identical to bpo-6028 and may be related to bpo-3555.

    19. birkenfeld commented on Dec 24, 2011

      @birkenfeld
      Member

      Nothing, but that would be pointless; the recursion would just start again.

      Why?

    20. benjaminp commented on Dec 24, 2011

      @benjaminp
      Contributor

      2011/12/24 Georg Brandl <[email protected]>:

      Georg Brandl <[email protected]> added the comment:

      > Nothing, but that would be pointless; the recursion would just start again.

      Because it would be caught in the function call above in the stack?

    21. birkenfeld commented on Dec 24, 2011

      @birkenfeld
      Member

      Would it?

    22. benjaminp commented on Dec 24, 2011

      @benjaminp
      Contributor

      2011/12/24 Georg Brandl <[email protected]>:

      Georg Brandl <[email protected]> added the comment:

      Would it?

      (<class 'Exception'>,)

    23. benjaminp commented on Dec 24, 2011

      @benjaminp
      Contributor

      Basically forget my last 3 messages.

    24. terryjreedy commented on Dec 24, 2011

      @terryjreedy
      Member

      @maniram I know what IDLE does. For the tracker, a 'bug' is a discrepancy between doc and behavior. According to the doc, a recursion loop should continue forever, just like an iteration loop ;=).

      Anyway, Roger is right, this is a duplicate of bpo-6028, which has at least a preliminary patch.

    25. 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)type-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions