Skip to content

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

Description

@marckwei

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)type-crashA hard crash of the interpreter, possibly with a core dump

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions