Skip to content

gh-137562: Fix github-issue number with deallocated objects in cache #137614

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

sergey-miryanov
Copy link
Contributor

@sergey-miryanov sergey-miryanov commented Aug 10, 2025

@nascheme It seems that #135552 should be referenced in following text:

 * However, since tp_subclasses started being necessary
 * to invalidate caches (e.g. by PyType_Modified), that clearing has created
 * a bug.  If the weakref to the subclass is cleared before a finalizer is
 * called, the cache may not be correctly invalidated.  That can lead to
 * segfaults since the caches can refer to deallocated objects (GH-135552
 * is an example).

Please take a look.

@sergey-miryanov
Copy link
Contributor Author

This should skip news I believe.

@nascheme
Copy link
Member

Yes, you are correct. GH-91636 is caused by not clearing weakrefs so objects that have tp_clear called on them can later get exposed to Python-level code.

@nascheme nascheme merged commit 654b8d9 into python:main Aug 12, 2025
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants