-
Notifications
You must be signed in to change notification settings - Fork 118
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
Fix leaks in gui_helper_3_helper_
.
#3256
base: master
Are you sure you want to change the base?
Conversation
The facts are: * `PyTuple_SetItem` steals its third argument [1]. * `hocobj_new` returns a new reference. * `cpp2refstr` returns a new reference. In both cases the reason it leaks is that `hocobj_new` or `cpp2refstr` creates a new reference, then the reference count is increased once more. The once reference is stolen by `PyTuple_SetItem`; but there's still one INCREF which we can't pair up with a matching DECREF. [1]: https://docs.python.org/3.12/c-api/tuple.html#c.PyTuple_SetItem
Quality Gate passedIssues Measures |
✔️ e68cc45 -> Azure artifacts URL |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3256 +/- ##
=======================================
Coverage 67.09% 67.09%
=======================================
Files 570 570
Lines 111082 111081 -1
=======================================
Hits 74525 74525
+ Misses 36557 36556 -1 ☔ View full report in Codecov by Sentry. |
@nrnhines The issue is that because we do manual reference counting, the following entirely made up sequence of steps might be possible:
Or it's just a leak that can be fixed as proposed in this PR. However, since it's GUI related it's likely not covered by the tests, which is why I'd like to ask you if you think merging this PR is a good idea. |
The facts are:
PyTuple_SetItem
steals its third argument 1.hocobj_new
returns a new reference.cpp2refstr
returns a new reference.In both cases the reason it leaks is that
hocobj_new
orcpp2refstr
creates a new reference, then the reference count is increased once more. The one reference is stolen byPyTuple_SetItem
; but there's still one INCREF which we can't pair up with a DECREF.