GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GenericAlias crashes when an argument gains __typing_subst__ after parameters are cached · Issue #155752 · python/cpython

GenericAlias crashes when an argument gains __typing_subst__ after parameters are cached #155752

New issue
Copy link
New issue
Copy link
Closed
#155761
Closed
GenericAlias crashes when an argument gains __typing_subst__ after parameters are cached#155752
#155761
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-typingtype-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump

Description

@dariushoule
dariushoule
opened on Aug 13, 2026
Issue body actions

Crash report

What happened?

types.GenericAlias calculates its __parameters__ only when they are first needed, then caches the result on the alias.

If an argument gains a __typing_subst__ attribute after the result has been cached, the cached parameters no longer match the alias arguments. During a later substitution, _Py_subs_parameters() recognizes the changed argument as a parameter but cannot find it in the cached tuple, so tuple_index() returns -1.

In a debug build, this triggers a failed C assertion. In a release build, the -1 is used as an array index and can crash the process.

class Parameter:
    pass

first = Parameter()
first.__typing_subst__ = lambda value: value
late = Parameter()

alias = dict[first, late]
alias.__parameters__
late.__typing_subst__ = lambda value: value
alias[0,]

CPython versions tested on:

3.15, 3.14, 3.13, 3.12, 3.11

Operating systems tested on:

macOS, Linux

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

Python 3.14.6 (main, Jun 10 2026, 10:03:53) [Clang 21.0.0 (clang-2100.0.123.102)]

Linked PRs

  • gh-155752: Do not crash when GenericAlias parameters change during substitution #155761
  • [3.15] gh-155752: Do not crash when GenericAlias parameters change during substitution (GH-155761) #155770
  • [3.14] gh-155752: Do not crash when GenericAlias parameters change during substitution (GH-155761) #155771
  • [3.13] gh-155752: Do not crash when GenericAlias parameters change during substitution (GH-155761) #155772

Activity

  1. dariushoule
    added
    type-crashA hard crash of the interpreter, possibly with a core dumpA hard crash of the interpreter, possibly with a core dump
    on Aug 13, 2026
  2. dariushoule
    changed the title [-]GenericAlias parameter substitution can crash on a missed cached parameter[/-] [+]GenericAlias crashes when an argument gains __typing_subst__ after parameters are cached[/+] on Aug 13, 2026
  3. JelleZijlstra
    added
    topic-typing
    on Aug 13, 2026
  4. dariushoule
    added a commit that references this issue on Aug 13, 2026

    pythongh-155752: Do not crash when GenericAlias parameters change dur…

    7a1932e
  5. picnixz
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on Aug 13, 2026
  6. JelleZijlstra
    added a commit that references this issue on Aug 14, 2026

    gh-155752: Do not crash when GenericAlias parameters change during su…

    c0006fa
  7. JelleZijlstra
    closed this as completedin #155761on Aug 14, 2026
  8. hugovk
    added a commit that references this issue on Aug 14, 2026

    [3.15] gh-155752: Do not crash when GenericAlias parameters change du…

    b8a9987
  9. mbeijen
    added a commit that references this issue on Aug 14, 2026

    pythongh-155752: Do not crash when GenericAlias parameters change dur…

    1772486
  10. terryjreedy
    added 2 commits that reference this issue on Sep 8, 2026

    [3.14] gh-155752: Do not crash when GenericAlias parameters change du…

    96964c8

    [3.13] gh-155752: Do not crash when GenericAlias parameters change du…

    649e421
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)(Objects, Python, Grammar, and Parser dirs)topic-typingtype-crashA hard crash of the interpreter, possibly with a core dumpA 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

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.