Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser crash #43965

Closed
loewis mannequin opened this issue Sep 12, 2006 · 8 comments
Closed

Parser crash #43965

loewis mannequin opened this issue Sep 12, 2006 · 8 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@loewis
Copy link
Mannequin

loewis mannequin commented Sep 12, 2006

BPO 1557232
Nosy @loewis, @birkenfeld
Files
  • ast-paren.diff: fix crash
  • ast-paren.diff: v2
  • tests.py: some simple tests
  • ast-paren.diff: v3
  • 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 2006-09-25.07:05:13.000>
    created_at = <Date 2006-09-12.15:28:52.000>
    labels = ['interpreter-core']
    title = 'Parser crash'
    updated_at = <Date 2006-09-25.07:05:13.000>
    user = 'https://github.com/loewis'

    bugs.python.org fields:

    activity = <Date 2006-09-25.07:05:13.000>
    actor = 'georg.brandl'
    assignee = 'none'
    closed = True
    closed_date = None
    closer = None
    components = ['Interpreter Core']
    creation = <Date 2006-09-12.15:28:52.000>
    creator = 'loewis'
    dependencies = []
    files = ['2141', '2142', '2143', '2144']
    hgrepos = []
    issue_num = 1557232
    keywords = []
    message_count = 8.0
    messages = ['29803', '29804', '29805', '29806', '29807', '29808', '29809', '29810']
    nosy_count = 3.0
    nosy_names = ['loewis', 'nnorwitz', 'georg.brandl']
    pr_nums = []
    priority = 'high'
    resolution = 'fixed'
    stage = None
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue1557232'
    versions = ['Python 2.5']

    @loewis
    Copy link
    Mannequin Author

    loewis mannequin commented Sep 12, 2006

    The code

    def x(((y))):pass 

    crashes the compiler (?) in 2.5c2, on Windows.

    @loewis loewis mannequin closed this as completed Sep 12, 2006
    @loewis loewis mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Sep 12, 2006
    @loewis loewis mannequin closed this as completed Sep 12, 2006
    @loewis loewis mannequin added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Sep 12, 2006
    @nnorwitz
    Copy link
    Mannequin

    nnorwitz mannequin commented Sep 13, 2006

    Logged In: YES
    user_id=33168

    The problem is in Python/ast.c around line 666. See the
    comment:

    /* def foo((x)): setup for checking NAME below. */

    The code is not sufficient, we need a loop and need to
    handle various combinations of:

    def f(((((x))),)),))): pass

    I don't know if the parens above match, but the general idea
    is that there could be a bunch of parens and commas at
    various places. I'm not sure how the above should be
    interpreted.

    @nnorwitz
    Copy link
    Mannequin

    nnorwitz mannequin commented Sep 13, 2006

    Logged In: YES
    user_id=33168

    I guess what 2.4 does is the most reasonable behavior:

    >>> def f((((((x)),),),)): pass
    >>> dis.dis(f)
      1           0 LOAD_FAST                0 (.0)
                  3 UNPACK_SEQUENCE          1
                  6 UNPACK_SEQUENCE          1
                  9 UNPACK_SEQUENCE          1
                 12 STORE_FAST               1 (x)
                 15 LOAD_CONST               0 (None)
                 18 RETURN_VALUE

    @nnorwitz
    Copy link
    Mannequin

    nnorwitz mannequin commented Sep 13, 2006

    Logged In: YES
    user_id=33168

    The attached patch seems to fix the ((((x)))) problem. I
    didn't run in debug mode, so I'm not positive the assert
    works as I expect.

    However now my test case below doesn't work, it puts in 5
    UNPACK_SEQUENCES rather than 3. This looks like a different
    problem in compiler_complex_args().

    Not sure how much farther I'll get tonight.

    @nnorwitz
    Copy link
    Mannequin

    nnorwitz mannequin commented Sep 13, 2006

    Logged In: YES
    user_id=33168

    I think patch v2 might fix both problems. I'm not sure it's
    correct. We really need a lot of tests for this stuff.

    @nnorwitz
    Copy link
    Mannequin

    nnorwitz mannequin commented Sep 18, 2006

    Logged In: YES
    user_id=33168

    Attaching a new patch with tests. There probably should be
    more tests, but this is all I can think of at this point. I
    think I've covered the cases of the recursive definition
    properly now.

    Conceptually this is a very small patch. I've added a bunch
    of asserts and broken some complex lines up though.

    The first chunk deals with complex_args and elides
    superfluous parens around (x). The second chunk does the
    same eliding but for non-complex args. Any number of extra
    parens should be elided properly now.

    I will apply to head and 2.5.1 later.

    @nnorwitz
    Copy link
    Mannequin

    nnorwitz mannequin commented Sep 22, 2006

    Logged In: YES
    user_id=33168

    Committed revision 51972. (2.6)
    Still needs backport.

    @birkenfeld
    Copy link
    Member

    Logged In: YES
    user_id=849994

    Backported in rev. 51999.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant