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.

classification
Title: TextIOWrapper assertion failure after read() and SEEK_CUR
Type: crash Stage: resolved
Components: IO Versions: Python 3.8, Python 3.7, Python 3.6, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: ZackerySpytz, martin.panter, miss-islington, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2015-12-15 01:43 by martin.panter, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3918 merged ZackerySpytz, 2017-10-07 16:28
PR 8007 merged miss-islington, 2018-06-29 10:16
PR 8012 merged ZackerySpytz, 2018-06-29 18:59
PR 8013 merged ZackerySpytz, 2018-06-29 19:45
PR 8026 merged serhiy.storchaka, 2018-06-30 13:29
PR 8028 merged miss-islington, 2018-06-30 17:59
PR 8029 merged miss-islington, 2018-06-30 18:01
PR 8033 merged serhiy.storchaka, 2018-06-30 18:25
Messages (12)
msg256430 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-12-15 01:43
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.
msg320312 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-23 16:26
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().
msg320709 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-29 10:15
New changeset 23db935bcf258657682e66464bf8512def8af830 by Serhiy Storchaka (Zackery Spytz) in branch 'master':
bpo-25862: Fix assertion failures in io.TextIOWrapper.tell(). (GH-3918)
https://github.com/python/cpython/commit/23db935bcf258657682e66464bf8512def8af830
msg320710 - (view) Author: miss-islington (miss-islington) Date: 2018-06-29 10:34
New changeset eabebbb54c2604fd8d08e8019ea1be634aed8c2f by Miss Islington (bot) in branch '3.7':
bpo-25862: Fix assertion failures in io.TextIOWrapper.tell(). (GH-3918)
https://github.com/python/cpython/commit/eabebbb54c2604fd8d08e8019ea1be634aed8c2f
msg320732 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-29 19:30
New changeset d6a283b37b66ecd2d0ff43602ddc8e91b54a51c5 by Serhiy Storchaka (Zackery Spytz) in branch '3.6':
[3.6] bpo-25862: Fix assertion failures in io.TextIOWrapper.tell(). (GH-3918). (GH-8012)
https://github.com/python/cpython/commit/d6a283b37b66ecd2d0ff43602ddc8e91b54a51c5
msg320737 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-29 20:07
New changeset 0464de0f9a226cfa32b803e0326c12b2432aba26 by Serhiy Storchaka (Zackery Spytz) in branch '2.7':
[2.7] bpo-25862: Fix assertion failures in io.TextIOWrapper.tell(). (GH-3918). (GH-8013)
https://github.com/python/cpython/commit/0464de0f9a226cfa32b803e0326c12b2432aba26
msg320780 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-30 13:33
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.
msg320798 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-06-30 17:57
New changeset fdb5a50ef34f7951c3b01eb77b1359725a9ad670 by Serhiy Storchaka in branch 'master':
bpo-25862: Fix several bugs in the _io module. (GH-8026)
https://github.com/python/cpython/commit/fdb5a50ef34f7951c3b01eb77b1359725a9ad670
msg320802 - (view) Author: miss-islington (miss-islington) Date: 2018-06-30 18:25
New changeset dedb28efd84314d899f795e821a3fc27d2f928e7 by Miss Islington (bot) in branch '3.7':
bpo-25862: Fix several bugs in the _io module. (GH-8026)
https://github.com/python/cpython/commit/dedb28efd84314d899f795e821a3fc27d2f928e7
msg320803 - (view) Author: miss-islington (miss-islington) Date: 2018-06-30 18:25
New changeset e5153d0d404d58e83d802199bea1a8dd0ea5178e by Miss Islington (bot) in branch '3.6':
bpo-25862: Fix several bugs in the _io module. (GH-8026)
https://github.com/python/cpython/commit/e5153d0d404d58e83d802199bea1a8dd0ea5178e
msg331024 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-12-04 10:02
New changeset eab421bff954e4fb77516bfe6c98d30ced1412d0 by Serhiy Storchaka in branch '2.7':
[2.7] bpo-25862: Fix several bugs in the _io module. (GH-8026) (GH-8033)
https://github.com/python/cpython/commit/eab421bff954e4fb77516bfe6c98d30ced1412d0
msg335118 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2019-02-08 23:20
I haven’t confirmed, but it looks like the original change here broke bidirectional reading and writing with a single TextIOWrapper object; see Issue 35928.
History
Date User Action Args
2022-04-11 14:58:24adminsetgithub: 70049
2019-02-08 23:20:42martin.pantersetmessages: + msg335118
2018-12-04 10:47:52serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2018-12-04 10:02:59serhiy.storchakasetmessages: + msg331024
2018-06-30 18:25:52miss-islingtonsetmessages: + msg320803
2018-06-30 18:25:39miss-islingtonsetmessages: + msg320802
2018-06-30 18:25:00serhiy.storchakasetpull_requests: + pull_request7642
2018-06-30 18:01:00miss-islingtonsetpull_requests: + pull_request7640
2018-06-30 17:59:08miss-islingtonsetpull_requests: + pull_request7639
2018-06-30 17:57:53serhiy.storchakasetmessages: + msg320798
2018-06-30 13:33:01serhiy.storchakasetassignee: serhiy.storchaka
messages: + msg320780
versions: + Python 2.7, Python 3.8
2018-06-30 13:29:09serhiy.storchakasetpull_requests: + pull_request7638
2018-06-29 20:07:16serhiy.storchakasetmessages: + msg320737
2018-06-29 19:45:35ZackerySpytzsetpull_requests: + pull_request7621
2018-06-29 19:30:15serhiy.storchakasetmessages: + msg320732
2018-06-29 18:59:31ZackerySpytzsetpull_requests: + pull_request7619
2018-06-29 10:34:38miss-islingtonsetnosy: + miss-islington
messages: + msg320710
2018-06-29 10:16:12miss-islingtonsetpull_requests: + pull_request7612
2018-06-29 10:15:01serhiy.storchakasetmessages: + msg320709
2018-06-23 16:26:15serhiy.storchakasetmessages: + msg320312
2017-11-07 23:42:06ZackerySpytzsetnosy: + ZackerySpytz

versions: + Python 3.6, Python 3.7, - Python 3.5
2017-10-07 16:28:04ZackerySpytzsetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request3891
2015-12-18 18:33:32serhiy.storchakasetnosy: + serhiy.storchaka

stage: needs patch
2015-12-15 01:43:10martin.pantercreate