Title: gh-135552: Make the GC clear weakrefs later by nascheme · Pull Request #136189 · python/cpython · GitHub
Open Graph Title: gh-135552: Make the GC clear weakrefs later by nascheme · Pull Request #136189 · python/cpython
X Title: gh-135552: Make the GC clear weakrefs later by nascheme · Pull Request #136189 · python/cpython
Description: Fix two bugs related to the interaction of weakrefs and the garbage collector. The weakrefs in the tp_subclasses dictionary are needed in order to correctly invalidate type caches (for example, by calling PyType_Modified()). Clearing weakrefs before calling finalizers causes the caches to not be correctly invalidated. That can cause crashes since the caches can refer to invalid objects. This is fixed by deferring the clearing of weakrefs to classes and without callbacks until after finalizers are executed. The second bug is caused by weakrefs created while running finalizers. Those weakrefs can be outside the set of unreachable garbage and therefore survive the delete_garbage() phase (where tp_clear() is called on objects). Those weakrefs can expose to Python-level code objects that have had tp_clear() called on them. See GH-91636 as an example of this kind of bug. This is fixed be clearing all weakrefs to unreachable objects after finalizers have been executed. Issue: gh-135552 Issue: gh-132413 Issue: gh-91636
Open Graph Description: Fix two bugs related to the interaction of weakrefs and the garbage collector. The weakrefs in the tp_subclasses dictionary are needed in order to correctly invalidate type caches (for example, by ...
X Description: Fix two bugs related to the interaction of weakrefs and the garbage collector. The weakrefs in the tp_subclasses dictionary are needed in order to correctly invalidate type caches (for example, by ...
Opengraph URL: https://github.com/python/cpython/pull/136189
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/checks(.:format) |
| route-controller | pull_requests |
| route-action | checks |
| fetch-nonce | v2:2714fb71-9b06-5a85-0300-d410b6e69f01 |
| current-catalog-service-hash | 87dc3bc62d9b466312751bfd5f889726f4f1337bdff4e8be7da7c93d6c00a25a |
| request-id | 9F5E:3F4FF7:2F71D3:3D5559:696B3C0A |
| html-safe-nonce | 5b59b395b8dcfe7f7cb87fae77d167fe73409fb8174d59aada196e62afcac22d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RjVFOjNGNEZGNzoyRjcxRDM6M0Q1NTU5OjY5NkIzQzBBIiwidmlzaXRvcl9pZCI6IjE3ODgzMTU1NTc5NDE2ODkzNTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 2b7ed00eff491164b202515168d4ba1249e077f2d10e52a8b93b05fc9333572b |
| hovercard-subject-tag | pull_request:2633601352 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,checks,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/python/cpython/pull/136189/checks |
| twitter:image | https://avatars.githubusercontent.com/u/690853?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/690853?s=400&v=4 |
| og:image:alt | Fix two bugs related to the interaction of weakrefs and the garbage collector. The weakrefs in the tp_subclasses dictionary are needed in order to correctly invalidate type caches (for example, by ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-cache |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive full-width full-width-p-0 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width