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

gh-129640: Add tests for reference cycle in gzip.GzipFile #130916

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

Mr-Sunglasses
Copy link
Contributor

@Mr-Sunglasses Mr-Sunglasses commented Mar 6, 2025

@ZeroIntensity ZeroIntensity added needs backport to 3.12 bug and security fixes needs backport to 3.13 bugs and security fixes labels Mar 6, 2025
Copy link
Member

@ZeroIntensity ZeroIntensity left a comment

Choose a reason for hiding this comment

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

Some triage nits.

Mr-Sunglasses and others added 2 commits March 6, 2025 21:50
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
Copy link
Contributor Author

@Mr-Sunglasses Mr-Sunglasses left a comment

Choose a reason for hiding this comment

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

Thanks @ZeroIntensity for the suggestions, I've made the change 😄

Copy link
Contributor

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Why is the weakref not sufficient?

@bedevere-app
Copy link

bedevere-app bot commented Mar 7, 2025

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@cmaloney
Copy link
Contributor

cmaloney commented Mar 7, 2025

I think just timing / this issue was added before, PR added after, didn't see this issue when I was working on the other one.

Could you check if the issue is resolved with current main and/or 3.12 branch? I think #130055 should have fixed it as well as what it was directly trying to address (bad destruction order) by adding a weakref.

I do like the testing for number of GCd object test / think that would be good to add regardless

@Mr-Sunglasses
Copy link
Contributor Author

Why is the weakref not sufficient?

I think just timing / this issue was added before, PR added after, didn't see this issue when I was working on the other one.

Could you check if the issue is resolved with current main and/or 3.12 branch? I think #130055 should have fixed it as well as what it was directly trying to address (bad destruction order) by adding a weakref.

I do like the testing for number of GCd object test / think that would be good to add regardless

Thanks @cmaloney the issue is fixed in the main branch and 3.12 branch and sorry while looking in this issue, I was testing in my Python 3.13 and there it is reproducible, that is why i opened this PR and I did not see #130055 ( my bad 😅 ), So I think we need to backport #130055 it to 3.13.2 ? Also I'll remove the change, but I think as @cmaloney suggested we can add the tests.

cc. @hauntsaninja

TiA.

@cmaloney
Copy link
Contributor

cmaloney commented Mar 7, 2025

#130055 is backported to 3.12 and 3.13 (#130670 and #130669), so should be in the next minor release of both. According to the 3.13 Release Schedule (https://peps.python.org/pep-0719/), 3.13.3 bugfix release which should contain it is expected 2025-04-08.

@Mr-Sunglasses Mr-Sunglasses changed the title gh-129640: Fix reference cycle in gzip.GzipFile gh-129640: Add tests for reference cycle in gzip.GzipFile Mar 8, 2025
Copy link
Contributor Author

@Mr-Sunglasses Mr-Sunglasses left a comment

Choose a reason for hiding this comment

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

@cmaloney @hauntsaninja as of our discussions, I changed this PR for the tests for reference cycle in gzip.GzipFile.

  • Also I'm not sure if it needs any NEWS entry, please let me know it need one.

@Mr-Sunglasses
Copy link
Contributor Author

Requesting @hauntsaninja for a review.

Copy link
Contributor

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

This test passes on the commit prior to #130055, so I'm not sure it's testing what we want it to test. len(gc.get_objects()) is quite coarse, where does the magic 10 number come from? Can we instead get a weakref to the _WriteBufferStream and confirm it gets collected?

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.

4 participants