python / python/mypy

Segmentation fault for TypeVar("T", bound=Callable[..., "T"])

Open
#16,940 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

crash topic-type-variables
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

Crash Report

mypy runs into a segfault when using a TypeVar like this:

T = TypeVar("T", bound=Callable[..., "T"])

Traceback

Unfortunately, nothing useful shows up:

$ mypy --show-traceback /tmp/err.py 
Segmentation fault

To Reproduce

$ mypy /tmp/err.py 
Segmentation fault
from typing import TypeVar
from collections.abc import Callable

T = TypeVar("T", bound=Callable[..., "T"])

Your Environment

  • Mypy version used: mypy 1.8.0 (compiled: yes)
  • Mypy command-line flags: mypy /tmp/err.py
  • Mypy configuration options from mypy.ini (and other config files): none
  • Python version used: Python 3.11.7
  • Operating system and version: Calculate Linux Desktop 23 Cinnamon (Distributor ID: Gentoo)

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 reproducing the crash with Python 3.11.7 using the command mypy /tmp/err.py and the provided TypeVar example. Trace the failure from this minimal input through mypy's type-checking path; done means the example no longer causes a segmentation fault and its behavior is covered by an appropriate regression check.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.