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

parsetok(): Assertion `(intptr_t)(int)(a - line_start) == (a - line_start)' failed, when running get-pip.py #81784

Closed
vstinner opened this issue Jul 16, 2019 · 6 comments
Labels
3.8 only security fixes 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@vstinner
Copy link
Member

BPO 37603
Nosy @vstinner, @methane, @ambv, @serhiy-storchaka, @pablogsal
PRs
  • bpo-37603: tok_nextc() now also updates multi_line_start on REALLOC() #14789
  • Superseder
  • bpo-37433: syntax error in multiline f-string produces ~40k spaces output
  • Files
  • get-pip2.py
  • 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 2019-08-21.12:14:29.037>
    created_at = <Date 2019-07-16.09:52:21.415>
    labels = ['interpreter-core', '3.8', '3.9']
    title = "parsetok(): Assertion `(intptr_t)(int)(a - line_start) == (a - line_start)' failed, when running get-pip.py"
    updated_at = <Date 2019-08-21.12:14:29.036>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2019-08-21.12:14:29.036>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-08-21.12:14:29.037>
    closer = 'vstinner'
    components = ['Interpreter Core']
    creation = <Date 2019-07-16.09:52:21.415>
    creator = 'vstinner'
    dependencies = []
    files = ['48486']
    hgrepos = []
    issue_num = 37603
    keywords = ['patch', '3.8regression']
    message_count = 6.0
    messages = ['348008', '348027', '348655', '348660', '348663', '350075']
    nosy_count = 5.0
    nosy_names = ['vstinner', 'methane', 'lukasz.langa', 'serhiy.storchaka', 'pablogsal']
    pr_nums = ['14789']
    priority = None
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = '37433'
    type = None
    url = 'https://bugs.python.org/issue37603'
    versions = ['Python 3.8', 'Python 3.9']

    @vstinner
    Copy link
    Member Author

    bpo-16806 introduced a regression with the following change:

    commit 995d9b9 (refs/bisect/bad)
    Author: Anthony Sottile <asottile@umich.edu>
    Date: Sat Jan 12 20:05:13 2019 -0800

    bpo-16806: Fix `lineno` and `col_offset` for multi-line string tokens (GH-10021)
    

    get-pip.py does now crash:

    $ ./python get-pip.py --help
    python: Parser/parsetok.c:266: parsetok: Assertion `(intptr_t)(int)(a - line_start) == (a - line_start)' failed.
    Aborted (core dumped)

    Python 3.8 is also affected.

    get-pip.py comes from: https://bootstrap.pypa.io/get-pip.py

    Reproducing depends if REALLOC() returns a new pointer, see below.

    I attached get-pip2.py: simplified version which crash when using "./python get-pip2.py --help". If it doesn't crash, duplicate lines to make the file larger.

    --

    The root issue seems to be that tok->multi_line_start isn't updated on REALLOC() in tok_nextc():

                    newbuf = (char *)PyMem_REALLOC(newbuf,
                                                   newsize);
                    if (newbuf == NULL) {
                        tok->done = E_NOMEM;
                        tok->cur = tok->inp;
                        return EOF;
                    }
                    tok->buf = newbuf;
                    tok->cur = tok->buf + cur;
                    tok->line_start = tok->cur;

    I guess that multi_line_start should also be updated there?

                tok->multi_line_start = tok->cur;
    

    @vstinner vstinner added release-blocker 3.8 only security fixes 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) labels Jul 16, 2019
    @vstinner
    Copy link
    Member Author

    PR 14433 seems to fix this issue and it contains a test.

    My PR 14789 fixed get-pip.py, but it introduces another bug: I closed it.

    @ambv
    Copy link
    Contributor

    ambv commented Jul 29, 2019

    This is marked as release blocker but since BPO-37433 is still in review, I'm releasing 3.0b3 as is. Please resolve this by b4, I will block the last beta on this issue.

    @vstinner
    Copy link
    Member Author

    This is marked as release blocker but since BPO-37433 is still in review, I'm releasing 3.0b3 as is. Please resolve this by b4, I will block the last beta on this issue.

    That sounds reasonable to me.

    FYI I just approved (but not merged) PR 14433.

    @pablogsal
    Copy link
    Member

    I just merged PR 14433

    @vstinner
    Copy link
    Member Author

    This issue is a duplicate of bpo-37433 which has been fixed.

    @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
    3.8 only security fixes 3.9 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs)
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants