Skip to content

Segfault in Interpreter.exec() when the uncaught exception's __str__ raises #161996

Open

Description

@aisk

Crash report

A custom exception whose __str__ also raises will crash the process when it is raised in a subinterpreter.

from concurrent import interpreters

interp = interpreters.create()
interp.exec("""
class MyError(Exception):
    def __str__(self):
        raise ValueError

raise MyError
""")
Assertion failed: (_PyErr_Occurred(tstate)), function _PyXI_Exit, file crossinterp.c, line 2872.
fish: Job 1, './python.exe a.py' terminated by signal SIGABRT (Abort)

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

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

No response

Linked PRs

Activity

  1. added
    type-crashA hard crash of the interpreter, possibly with a core dump
    on Nov 14, 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

    extension-modulesC modules in the Modules dirtopic-subprocessSubprocess issues.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