Title: Clear cyclic references in base exception payloads · Issue #9738 · RustPython/RustPython · GitHub
Open Graph Title: Clear cyclic references in base exception payloads · Issue #9738 · RustPython/RustPython
X Title: Clear cyclic references in base exception payloads · Issue #9738 · RustPython/RustPython
Description: Summary PyBaseException uses the default no-op Traverse::clear. An owned exception whose cause points to itself can remain alive after the collector untracks it. The generated one-field wrapper forwards clear through MaybeTraverse::try_c...
Open Graph Description: Summary PyBaseException uses the default no-op Traverse::clear. An owned exception whose cause points to itself can remain alive after the collector untracks it. The generated one-field wrapper for...
X Description: Summary PyBaseException uses the default no-op Traverse::clear. An owned exception whose cause points to itself can remain alive after the collector untracks it. The generated one-field wrapper for...
Opengraph URL: https://github.com/RustPython/RustPython/issues/9738
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Clear cyclic references in base exception payloads","articleBody":"## Summary\n\n`PyBaseException` uses the default no-op `Traverse::clear`. An owned exception whose cause points to itself can remain alive after the collector untracks it. The generated one-field wrapper forwards `clear` through `MaybeTraverse::try_clear`, but forwarding alone does not break the cycle.\n\nThis limitation predates the owned exception payload construction change. The existing weakref regression checks traversal and weakref invalidation; it does not prove that the exception payload is destroyed.\n\n## Required changes\n\n- Implement base exception payload clearing in `crates/vm/src/exceptions.rs` so GC can break cyclic references safely.\n- Preserve the generated wrapper clear forwarding in `crates/derive-impl/src/pyclass.rs`.\n- Add regression coverage in the VM GC tests that observes actual payload destruction, not only weakref invalidation. Include an owned exception with a self-cause cycle.\n\n## Acceptance criteria\n\n- After external references are dropped and GC runs, the self-cause cycle is broken and the exception payload is destroyed.\n- The regression test fails when base payload clearing is a no-op and passes with the repair.\n- Existing exception construction and GC tests continue to pass.\n\nRequested by @JMLX42.\n\nRelated pull request: https://github.com/RustPython/RustPython/pull/9734\nReview thread: https://github.com/RustPython/RustPython/pull/9734#discussion_r4500303098","author":{"url":"https://github.com/apps/coderabbitai","@type":"Person","name":"coderabbitai"},"datePublished":"2026-11-07T10:14:58Z","url":"https://github.com/RustPython/RustPython/issues/9738"}
| 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:2ea95ece-8a80-da34-9caa-61e8b10d5b50 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C556:2F543F:E8FF54:134C114:6B01D40C |
| html-safe-nonce | 6ec5897baa1b783f0ec9d712ad4290feefac252ae45bd8ccfb156f77a9bf3182 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNTU2OjJGNTQzRjpFOEZGNTQ6MTM0QzExNDo2QjAxRDQwQyIsInZpc2l0b3JfaWQiOiI2NjAwNDE1NDMyMDEwNzQ4OTQwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 49059df7d44f48e47d544e535c6481d5259fe64131d6e270a0327d47fb0341a2 |
| hovercard-subject-tag | issue:6257827602 |
| 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/RustPython/RustPython/9738/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4944ae8411cae0195a31f59084670e8422c333ce17a7bcb7480c38fc8e730674/RustPython/RustPython/issues/9738 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4944ae8411cae0195a31f59084670e8422c333ce17a7bcb7480c38fc8e730674/RustPython/RustPython/issues/9738 |
| og:image:alt | Summary PyBaseException uses the default no-op Traverse::clear. An owned exception whose cause points to itself can remain alive after the collector untracks it. The generated one-field wrapper for... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | coderabbitai[bot] |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/RustPython/RustPython git https://github.com/RustPython/RustPython.git |
| octolytics-dimension-user_id | 39710557 |
| octolytics-dimension-user_login | RustPython |
| octolytics-dimension-repository_id | 135201145 |
| octolytics-dimension-repository_nwo | RustPython/RustPython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 135201145 |
| octolytics-dimension-repository_network_root_nwo | RustPython/RustPython |
| 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 | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width