Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Free arena on _PyCompile_AstOptimize failure in Py_CompileStringObject #127910

Merged

Conversation

berkerpeksag
Copy link
Member

After commit 10a91d7 introduced arena cleanup, commit 2dfbd4f removed the free call when _PyCompile_AstOptimize fails.

After commit 10a91d7 introduced arena cleanup, commit 2dfbd4f
removed the free call when _PyCompile_AstOptimize fails.
@Eclips4 Eclips4 added the needs backport to 3.13 bugs and security fixes label Dec 14, 2024
@iritkatriel
Copy link
Member

How did you find this? Are you able to write a test?

@berkerpeksag
Copy link
Member Author

I saw the snippet of Py_CompileStringObject in a blog post. I'll see what can I do about writing a minimal test case.

@berkerpeksag
Copy link
Member Author

I took some time to think about how to write a test. If this were a refleak, I would probably launch a Python process with -X showrefcount and make sure that the leak is no longer present. Since this case involves forgetting to free the arena, I can't think of a reliable way to confirm that the leak is fixed in the test case.

Also, it seems that the only way to trigger this issue is by testing Py_CompileStringObject directly in test_capi, which feels a bit excessive.

@berkerpeksag berkerpeksag merged commit cfeaa99 into python:main Dec 16, 2024
51 checks passed
@miss-islington-app
Copy link

Thanks @berkerpeksag for the PR 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@berkerpeksag berkerpeksag deleted the free-arena-in-py-compile-string-object branch December 16, 2024 20:59
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Dec 16, 2024
pythonGH-127910)

After commit 10a91d7 introduced arena cleanup, commit 2dfbd4f
removed the free call when _PyCompile_AstOptimize fails.
(cherry picked from commit cfeaa99)

Co-authored-by: Berker Peksag <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Dec 16, 2024

GH-128006 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Dec 16, 2024
berkerpeksag added a commit that referenced this pull request Dec 16, 2024
…ngObject (GH-128006)

Free arena on _PyCompile_AstOptimize failure in Py_CompileStringObject (GH-127910)

After commit 10a91d7 introduced arena cleanup, commit 2dfbd4f
removed the free call when _PyCompile_AstOptimize fails.

(cherry picked from commit cfeaa99)

Co-authored-by: Berker Peksag <[email protected]>
srinivasreddy pushed a commit to srinivasreddy/cpython that referenced this pull request Jan 8, 2025
pythonGH-127910)

After commit 10a91d7 introduced arena cleanup, commit 2dfbd4f
removed the free call when _PyCompile_AstOptimize fails.
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.

3 participants