python / python/cpython

SIGSEGV in TextIOWrapper.readline() after seek() with cookie containing negative chars_to_skip

Open
#153,662 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

interpreter-core type-crash
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Crash report

What happened?
import io, sys

COOKIE_VALUE = (100 << (12 * 8)) | (0x80 << (19 * 8))

data = b"Hello World!" * 100
raw = io.BytesIO(data)
buf = io.BufferedReader(raw)
tio = io.TextIOWrapper(buf, encoding='utf-8')

tio.read(20)
tio.seek(COOKIE_VALUE)
tio.readline()

sys.exit(0)

CPython versions tested on:

3.16

Operating systems tested on:

Linux

Output from running 'python -VV' on the command line:

Python 3.16.0a0 (tags/v3.15.0b1-959-gd0714388278:d0714388278, Jul 13 2026, 20:32:55) [GCC 12.3.0] Linux x86_64, GCC 12.3.0

Linked PRs
  • gh-153667

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the supplied Python reproducer on Linux and inspect the io.TextIOWrapper seek() and readline() entry points involved in the crash. Done means the same cookie no longer causes a SIGSEGV and the reproducer exits normally; review linked PR gh-153667 before starting because work may already be underway.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.