Skip to content

gh-162412: Fix a ctypes callback argument reference leak on Windows - #162413

Open
manabeai wants to merge 4 commits into
python:mainfrom
manabeai:gh-162412-ctypes-callback-leak
Open

manabeai wants to merge 4 commits into
python:mainfrom
manabeai:gh-162412-ctypes-callback-leak

Conversation

@manabeai

@manabeai manabeai commented Nov 22, 2026 •

Copy link
Copy Markdown

Fixes #162412.

Release the current callback argument when TryAddRef() fails on Windows. The shared cleanup loop releases only the arguments converted before the failure.

The Windows regression test checks that the callback is skipped and that the temporary arguments are released. The test method failed at the weak-reference assertion on stock CPython 3.14.10 (Windows x64) and passed on a local 3.14.10 build with the fix. The standalone probe reported 128 retained arguments before the fix and zero after it.

@python-cla-bot

python-cla-bot Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-22T03:30:05.449464Z 7d58fb9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7d58fb9782

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Modules/_ctypes/callbacks.c Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ctypes: Windows callback argument reference leak when TryAddRef fails

1 participant