python / python/cpython

Refactor `codegen_deferred_annotations_body` to ensure `mangled` is decref'd

Open
#148,059 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

interpreter-core type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

Follow-up item from this PR: https://github.com/python/cpython/pull/146443#pullrequestreview-4033013919

During error cases we may fail to decref mangled while using these ADDOP* and VISIT macros. As a result, we can extract the for loop's body into a subfunction that we check the return of and decref mangled if needed.

        // NOTE: ref of mangled can be leaked on ADDOP* and VISIT macros due to early returns
        // fixing would require an overhaul of these macros
CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

Linked PRs
  • gh-148060

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating codegen_deferred_annotations_body and inspect the for-loop using the ADDOP* and VISIT macros, then review linked PR 146443 and PR 148060 for context. Done means the loop's error path no longer leaves mangled unreleased while preserving the existing code-generation behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.