This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients lukasz.langa, vstinner
Date 2019-07-16.09:52:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1563270741.47.0.416934432776.issue37603@roundup.psfhosted.org>
In-reply-to
Content
bpo-16806 introduced a regression with the following change:

commit 995d9b92979768125ced4da3a56f755bcdf80f6e (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;
History
Date User Action Args
2019-07-16 09:52:21vstinnersetrecipients: + vstinner, lukasz.langa
2019-07-16 09:52:21vstinnersetmessageid: <1563270741.47.0.416934432776.issue37603@roundup.psfhosted.org>
2019-07-16 09:52:21vstinnerlinkissue37603 messages
2019-07-16 09:52:21vstinnercreate