Skip to content

Use-after-free in OSError.__str__ when a formatting callback clears filename #160773

Description

@charliermarsh

Crash report

The following segfaults on CPython 3.14.5 and 3.15.0 (at least):

class Text:
    def __repr__(self):
        error.filename = None
        return 'message'

error = OSError(2, Text(), Text())
str(error)

CPython versions tested on:

3.15

Operating systems tested on:

Linux

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

Python 3.15.0 (main, Oct 9 2026, 15:11:47) [Clang 22.1.3 ]

Linked PRs

Activity

  1. added
    type-crashA hard crash of the interpreter, possibly with a core dump
    on Oct 27, 2026
  2. added a commit that references this issue on Oct 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions