Skip to content

Release debugger frame references after formatting - #257

Open
x0Lazarus wants to merge 1 commit into
gruns:masterfrom
x0Lazarus:fix/frame-reference-cycle
Open

x0Lazarus wants to merge 1 commit into
gruns:masterfrom
x0Lazarus:fix/frame-reference-cycle

Conversation

@x0Lazarus

Copy link
Copy Markdown

Related to #118.

Both ic(...) and ic.format(...) keep their own frame in a local variable. That creates a reference cycle, so arguments and other locals in the calling function can stay alive until cyclic garbage collection runs. The retention also occurs with a trivial formatter that never calls executing.

Delete the frame reference in finally so it is released after normal output and when formatting or output raises. This breaks the cycle without adding a garbage-collection sweep to each call.

Validation on Windows with CPython 3.12.14:

  • The new tests pass with this change. The lifetime regression cases fail on the unchanged source, while the disabled-call control passes. Coverage includes arguments, caller locals, retained return values, and formatting/output exceptions.
  • The full suite has 72 passes and one existing error in test_context_abs_path_multi_line, whose helper splits a Windows drive-letter path on :. The same error occurs on the unchanged source.
  • The project-pinned mypy 1.7.1 passes all five source files.

The lifetime tests require CPython's reference-counting behavior and are skipped on other interpreters. I have not reproduced the Qt application from #118; this change addresses the independently reproduced frame-retention problem. Hosted checks have not run yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant