-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
gh-116946: Remove gc-support from some immutable types #139073
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-116946: Remove gc-support from some immutable types #139073
Conversation
As @picnixz suggested this should skip news. |
This ready to review, please take a look. |
I'll have a look tomorrow or later tonight |
Be careful not to create ref cycles. At least, |
That's news to me! Could you have a look at the types I said "no need" to see if it's really the case? or link the relevant docs (I'm on mobile) |
Heaptype without GC is not recommended/clarified to users for its complexity of holding/freeing the module properly: #118021 (comment) Regarding the module:type cycle, it looks to me like the following:
|
I'm not sure I get it. IIUC, the Maybe I'm missing something? |
Probably I'm wrong. After reading the PEP-573 again, I realized it says that the module finalization phase breaks the module:type cycle even without the GC. If I'm reading correctly, I think the section still stands. I'll check what I'm missing. |
import gc, bz2
_ = bz2.BZ2Compressor()
gc.collect() It seems like #20960 just forgot to add the GC flag when the isolation howto is not yet established. |
Then we should restore GC-support for these types. @picnixz OK? |
And maybe check for other too. |
Let's put this on hold until we all agree about the fact that immutable empty types do not need a priori the GC but that they may require it in some exceptional cases (weird ones). Unless this is confirmed or corrected, let's not update the PR |
OK, maybe we can run refleak bots on this? Because
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, this is correct, see the issue for my explanation for thread handle false leak.
There seems to be a refleak in newly added ❯ ./python.exe -m test -R 3:3 test_capi.test_misc
Using random seed: 1923144239
0:00:00 load avg: 2.46 Run 1 test sequentially in a single process
0:00:00 load avg: 2.46 [1/1] test_capi.test_misc
beginning 6 repetitions. Showing number of leaks (. for 0 or less, X for 10 or more)
123:456
XXX XXX
test_capi.test_misc leaked [20, 20, 20] references, sum=60
test_capi.test_misc leaked [14, 14, 14] memory blocks, sum=42
0:00:54 load avg: 1.88 [1/1/1] test_capi.test_misc failed (reference leak) in 54.8 sec
== Tests result: FAILURE ==
1 test failed:
test_capi.test_misc
Total duration: 54.8 sec
Total tests: run=270 skipped=4
Total test files: run=1/1 failed=1
Result: FAILURE
I missed it as it didn't show up until I merged main into this locally while working on #139473. |
There was an FD leak on that test before, but we fixed it. Is it possible that this PR just had an old version of Otherwise, that looks like an actual leak. We shouldn't just put it in a subprocess to hide it. |
Likely as I did run the tests myself before merging.
Yeah, will revert this for now and investigate, the subprocess change I was doing was orthogonal to this and wasn't meant to hide it. |
…ython#139073)" This reverts commit 1588413.
Created partial revert PR here #139474 |
Well, this leak confirms what I noticed when I created the issue:
|
Hmm, I still think that the underlying issue is different and is an artifact of how refleak checker works, for example the os.register_at_fork never works correctly with the checker. I will look more into this after the revert. |
Remove gc-support from some immutable types (see discussion in linked issue):
Also fixed: