Title: Free-threading: weakref can revive an object being deallocated after its finalizer ran · Issue #161419 · python/cpython · GitHub
Open Graph Title: Free-threading: weakref can revive an object being deallocated after its finalizer ran · Issue #161419 · python/cpython
X Title: Free-threading: weakref can revive an object being deallocated after its finalizer ran · Issue #161419 · python/cpython
Description: Crash report On the free-threaded build, a weakref to an object whose deallocation is in progress can still be dereferenced after tp_finalize has run. Dropping that reference deallocates the object a second time. import io, weakref class...
Open Graph Description: Crash report On the free-threaded build, a weakref to an object whose deallocation is in progress can still be dereferenced after tp_finalize has run. Dropping that reference deallocates the object...
X Description: Crash report On the free-threaded build, a weakref to an object whose deallocation is in progress can still be dereferenced after tp_finalize has run. Dropping that reference deallocates the object...
Opengraph URL: https://github.com/python/cpython/issues/161419
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Free-threading: weakref can revive an object being deallocated after its finalizer ran","articleBody":"### Crash report\n\nOn the free-threaded build, a weakref to an object whose deallocation is in progress can\nstill be dereferenced after `tp_finalize` has run. Dropping that reference deallocates the\nobject a second time.\n\n```python\nimport io, weakref\n\nclass Raw(io.RawIOBase):\n __slots__ = ('a',)\n\nclass Attr:\n def __del__(self):\n print(\"weakref deref during dealloc ->\", self.wr())\n\no = Raw()\no.a = Attr()\no.a.wr = weakref.ref(o)\ndel o\n```\nDefault build: prints `None`. Free-threaded build: prints `\u003c__main__.Raw object at 0x...>`, then hangs or crashes on the second deallocation.\n\n### CPython versions tested on:\n\nCPython main branch\n\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-161431\n* gh-161483\n* gh-161488\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/eendebakpt","@type":"Person","name":"eendebakpt"},"datePublished":"2026-11-05T12:23:16Z","url":"https://github.com/python/cpython/issues/161419"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:68eab469-b415-a543-9f2c-e79cbf399436 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C7B2:3D97C8:359CF98:47495AA:6B020398 |
| html-safe-nonce | 6d60b2ffa468816645eac3db428b892c6c1674731f15e77452e2fcf66f202907 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDN0IyOjNEOTdDODozNTlDRjk4OjQ3NDk1QUE6NkIwMjAzOTgiLCJ2aXNpdG9yX2lkIjoiNjAwNDE4NDMxODE3ODYyNDQwOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 7db650faf3d848ee3366c273311983b7aa2a793618f81632cbb92d8f6157cbac |
| hovercard-subject-tag | issue:6223104378 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/python/cpython/161419/issue_layout |
| twitter:image | https://opengraph.githubassets.com/689e5dc65be67aacf40c3402286732be66bb9a2db939df4933e58cff2598aeee/python/cpython/issues/161419 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/689e5dc65be67aacf40c3402286732be66bb9a2db939df4933e58cff2598aeee/python/cpython/issues/161419 |
| og:image:alt | Crash report On the free-threaded build, a weakref to an object whose deallocation is in progress can still be dereferenced after tp_finalize has run. Dropping that reference deallocates the object... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | eendebakpt |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| 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 |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width