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

TextIOWrapper assertion failure after read() and SEEK_CUR #70049

Closed
vadmium opened this issue Dec 15, 2015 · 12 comments
Closed

TextIOWrapper assertion failure after read() and SEEK_CUR #70049

vadmium opened this issue Dec 15, 2015 · 12 comments
Assignees
Labels
3.7 (EOL) end of life 3.8 only security fixes topic-IO type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@vadmium
Copy link
Member

vadmium commented Dec 15, 2015

BPO 25862
Nosy @vadmium, @serhiy-storchaka, @ZackerySpytz, @miss-islington
PRs
  • bpo-25862: Fix an assertion failure in io.TextIOWrapper.tell(). #3918
  • [3.7] bpo-25862: Fix assertion failures in io.TextIOWrapper.tell(). (GH-3918) #8007
  • [3.6] bpo-25862: Fix assertion failures in io.TextIOWrapper.tell(). (GH-3918) #8012
  • [2.7] bpo-25862: Fix assertion failures in io.TextIOWrapper.tell(). (GH-3918) #8013
  • bpo-25862: Fix several bugs in the _io module. #8026
  • [3.7] bpo-25862: Fix several bugs in the _io module. (GH-8026) #8028
  • [3.6] bpo-25862: Fix several bugs in the _io module. (GH-8026) #8029
  • [2.7] bpo-25862: Fix several bugs in the _io module. (GH-8026) #8033
  • 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 = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2018-12-04.10:47:52.634>
    created_at = <Date 2015-12-15.01:43:10.182>
    labels = ['3.7', '3.8', 'expert-IO', 'type-crash']
    title = 'TextIOWrapper assertion failure after read() and SEEK_CUR'
    updated_at = <Date 2019-02-08.23:20:42.391>
    user = 'https://github.com/vadmium'

    bugs.python.org fields:

    activity = <Date 2019-02-08.23:20:42.391>
    actor = 'martin.panter'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2018-12-04.10:47:52.634>
    closer = 'serhiy.storchaka'
    components = ['IO']
    creation = <Date 2015-12-15.01:43:10.182>
    creator = 'martin.panter'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 25862
    keywords = ['patch']
    message_count = 12.0
    messages = ['256430', '320312', '320709', '320710', '320732', '320737', '320780', '320798', '320802', '320803', '331024', '335118']
    nosy_count = 4.0
    nosy_names = ['martin.panter', 'serhiy.storchaka', 'ZackerySpytz', 'miss-islington']
    pr_nums = ['3918', '8007', '8012', '8013', '8026', '8028', '8029', '8033']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue25862'
    versions = ['Python 2.7', 'Python 3.6', 'Python 3.7', 'Python 3.8']

    @vadmium
    Copy link
    Member Author

    vadmium commented Dec 15, 2015

    Python 3.5.1+ (3.5:014e6f7d7c1a, Dec 14 2015, 11:20:58) 
    [GCC 5.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from io import *
    >>> text = TextIOWrapper(BytesIO(b"x"), "ascii")
    >>> text.read(1)
    'x'
    >>> text.read()
    ''
    >>> text.seek(0, SEEK_CUR)
    python: ./Modules/_io/textio.c:2293: _io_TextIOWrapper_tell_impl: Assertion `self->decoded_chars == ((void *)0) || PyUnicode_GetLength(self->decoded_chars) == 0' failed.
    Aborted (core dumped)
    [Exit 134]

    May affect other versions; I haven’t looked.

    @vadmium vadmium added topic-IO type-crash A hard crash of the interpreter, possibly with a core dump labels Dec 15, 2015
    @ZackerySpytz ZackerySpytz mannequin added the 3.7 (EOL) end of life label Nov 7, 2017
    @serhiy-storchaka
    Copy link
    Member

    Similar case:

    text.read(1); text.write(b'x'); text.tell()

    And there may be crashes after setting self->snapshot to NULL due to the failure of Py_BuildValue().

    @serhiy-storchaka
    Copy link
    Member

    New changeset 23db935 by Serhiy Storchaka (Zackery Spytz) in branch 'master':
    bpo-25862: Fix assertion failures in io.TextIOWrapper.tell(). (GH-3918)
    23db935

    @miss-islington
    Copy link
    Contributor

    New changeset eabebbb by Miss Islington (bot) in branch '3.7':
    bpo-25862: Fix assertion failures in io.TextIOWrapper.tell(). (GH-3918)
    eabebbb

    @serhiy-storchaka
    Copy link
    Member

    New changeset d6a283b by Serhiy Storchaka (Zackery Spytz) in branch '3.6':
    [3.6] bpo-25862: Fix assertion failures in io.TextIOWrapper.tell(). (GH-3918). (GH-8012)
    d6a283b

    @serhiy-storchaka
    Copy link
    Member

    New changeset 0464de0 by Serhiy Storchaka (Zackery Spytz) in branch '2.7':
    [2.7] bpo-25862: Fix assertion failures in io.TextIOWrapper.tell(). (GH-3918). (GH-8013)
    0464de0

    @serhiy-storchaka
    Copy link
    Member

    The assertion failure can be also caused by setting self->snapshot to NULL when Py_BuildValue() fails due to lack of memory. It is very difficult to reproduce this. PR 8026 fixes this and other difficulty reproducible refcount bugs in the _io module.

    @serhiy-storchaka serhiy-storchaka added the 3.8 only security fixes label Jun 30, 2018
    @serhiy-storchaka serhiy-storchaka self-assigned this Jun 30, 2018
    @serhiy-storchaka
    Copy link
    Member

    New changeset fdb5a50 by Serhiy Storchaka in branch 'master':
    bpo-25862: Fix several bugs in the _io module. (GH-8026)
    fdb5a50

    @miss-islington
    Copy link
    Contributor

    New changeset dedb28e by Miss Islington (bot) in branch '3.7':
    bpo-25862: Fix several bugs in the _io module. (GH-8026)
    dedb28e

    @miss-islington
    Copy link
    Contributor

    New changeset e5153d0 by Miss Islington (bot) in branch '3.6':
    bpo-25862: Fix several bugs in the _io module. (GH-8026)
    e5153d0

    @serhiy-storchaka
    Copy link
    Member

    New changeset eab421b by Serhiy Storchaka in branch '2.7':
    [2.7] bpo-25862: Fix several bugs in the _io module. (GH-8026) (GH-8033)
    eab421b

    @vadmium
    Copy link
    Member Author

    vadmium commented Feb 8, 2019

    I haven’t confirmed, but it looks like the original change here broke bidirectional reading and writing with a single TextIOWrapper object; see bpo-35928.

    @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.7 (EOL) end of life 3.8 only security fixes topic-IO type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants