-
Notifications
You must be signed in to change notification settings - Fork 117
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
BugFix: Don't INCREF a Py section just allocated #3039
Conversation
✔️ 4d66983 -> Azure artifacts URL |
This comment has been minimized.
This comment has been minimized.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #3039 +/- ##
=======================================
Coverage 67.38% 67.39%
=======================================
Files 573 573
Lines 104936 104922 -14
=======================================
Hits 70711 70711
+ Misses 34225 34211 -14 ☔ View full report in Codecov by Sentry. |
I see the logic behind the change and agree that the INCREF looks very suspicious. IIUC a section is removed from a model, by letting the python object go out-of-scope. Once the object is GCed it's removed from the model. We have some tests that assert this. I mostly see RXD tests fail because of this. Also for this PR, but it's failing in exactly the way RXD is known to fail from time to time: #2939. This leak seems like something that changes the behaviour for users, i.e. it's a bug (because some section would refuse to be deleted from the model). Do you see a way we could increase our test-coverage to catch the bug? |
There is something else very suspicious. Notice that we let the created It might be worth more people to have a look. In the meantime I'll create a test |
✔️ 79891ce -> Azure artifacts URL |
This comment has been minimized.
This comment has been minimized.
✔️ 49a70be -> Azure artifacts URL |
This comment has been minimized.
This comment has been minimized.
✔️ 47b940f -> Azure artifacts URL |
This comment has been minimized.
This comment has been minimized.
✔️ 7caca61 -> Azure artifacts URL |
This comment has been minimized.
This comment has been minimized.
Pls let me know if you consider the test sufficient |
@nrnhines We need your input in wrt the right behavior of
|
This comment has been minimized.
This comment has been minimized.
✔️ 04637ce -> Azure artifacts URL |
✔️ 3f50c67 -> Azure artifacts URL |
✔️ fff7439 -> Azure artifacts URL |
✔️ 349d8a9 -> Azure artifacts URL |
349d8a9
to
8f9b1a4
Compare
✔️ e64040b -> Azure artifacts URL |
Quality Gate passedIssues Measures |
✔️ 7842703 -> Azure artifacts URL |
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.
Very nicely done!
Context
Following #3023, we noticed that there might be extraneous call to INCREF, given it's done on an object returned by
tp_alloc
, which should return a new reference. New references have their ref count to 1 and therefore it should not require any additional reference increment.Bug Reproducer
~$ nrniv -python
Exit the interpreter and observe
Scope
newpysechelp(sec)
which seems to do just the right thing.Testing
Two python unit tests added:
For debug-ability it might be worth to add the following snippet to
seg_from_sec_x
We will see along the lines of
ensuring the we are exercising both cases.
After dropping the original section, the pure-python code end up with the same number of references as the hoc-python code.