Skip to content

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

Closed

Description

@vstinner
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']

    Activity

    1. vstinner commented on Jul 16, 2019

      @vstinner
      MemberAuthor

      bpo-16806 introduced a regression with the following change:

      commit 995d9b9 (refs/bisect/bad)
      Author: Anthony Sottile <[email protected]>
      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;
      
    2. vstinner commented on Jul 16, 2019

      @vstinner
      MemberAuthor

      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.

    3. ambv commented on Jul 29, 2019

      @ambv
      Contributor

      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.

    4. vstinner commented on Jul 29, 2019

      @vstinner
      MemberAuthor

      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.

    5. pablogsal commented on Jul 29, 2019

      @pablogsal
      Member

      I just merged PR 14433

    6. vstinner commented on Aug 21, 2019

      @vstinner
      MemberAuthor

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

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

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions