Skip to content

PyType_Watch does not report deallocations #149216

Closed

Description

@markshannon

Bug report

Bug description:

The PyType_Watch function is used heavily in the JIT and we rely on it to deoptimize when a class changes.

However, it does not trigger the callback function when a class is deallocated
which can lead to the following situation.

  • We have jitted code that depends on the state of a class.
  • That code does a pointer comparison on the address of a watched class and then assumes that class to be identical to when the code was compiled.
  • The class is deallocated
  • Another, different class is allocated at the same address
  • Crash and burn

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Activity

  1. added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)
    and removed on May 4, 2026
  2. added a commit that references this issue on May 5, 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)topic-C-APItype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions