GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Clear cyclic references in base exception payloads · Issue #9738 · RustPython/RustPython

Clear cyclic references in base exception payloads #9738

New issue
Copy link
New issue
Copy link
Open
Open
Clear cyclic references in base exception payloads#9738
Copy link

Description

@coderabbitai
coderabbitai
bot
opened on Nov 7, 2026
Issue body actions

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_clear, but forwarding alone does not break the cycle.

This 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.

Required changes

  • Implement base exception payload clearing in crates/vm/src/exceptions.rs so GC can break cyclic references safely.
  • Preserve the generated wrapper clear forwarding in crates/derive-impl/src/pyclass.rs.
  • 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.

Acceptance criteria

  • After external references are dropped and GC runs, the self-cause cycle is broken and the exception payload is destroyed.
  • The regression test fails when base payload clearing is a no-op and passes with the repair.
  • Existing exception construction and GC tests continue to pass.

Requested by @JMLX42.

Related pull request: #9734
Review thread: #9734 (comment)

Reacted by Jean-Marc Le Roux

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.