-
Notifications
You must be signed in to change notification settings - Fork 748
Fix exception refcnt #1402
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 exception refcnt #1402
Conversation
As seen in exceptions.c (from cpython), derived exception classes must also clean the ExceptionBase members. If we don't, we leak the Python and C# objects set as the __cause__/Inner (amongst others) of thrown C# exceptions. This does not address the serializability of the PythonException class. Also fix various PythonException (ab)uses.
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.
Mostly NITs, but Clear and Normalize must be rechecked.
@BadSingleton can you investigate timeout in Ubuntu Py 3.6 tests? |
Huh.. that's weird. I'll take a look into it. |
I'm blocked due to #1412, this seems like an issue with garbage collection. This does raise the question of "How much do we care about Python 3.6?" There's less than a year before it's EOL: https://www.python.org/dev/peps/pep-0494/#lifespan . |
@BadSingleton is this still blocked? (Benedikt says "this needs a rebase") |
@mjmvisser @BadSingleton AFAIK you should now be able to use a debug build of Python. |
Apologies for the late reply, was on vacations. Yes this needs a rebase. I hadn't had the time to take a look at it in a while, but we're planning on resuming work on this Soon ™️ |
@BadSingleton can you please see if the issue is still present in |
Looks like cb4bb9a which re-enabled the test |
Originally from PR pythonnet#1402. The underlying bug is now fixed, but the tests are atill applicable.
Closing. Superseded by #1679 |
Originally from PR #1402. The underlying bug is now fixed, but the tests are atill applicable.
What does this implement/fix? Explain your changes.
Adds a tp_dealloc function to ExceptionClassObject, so we clean the BaseException members the same way as other the derived exceptions in the cpython code does.
Does this close any currently open issues?
Fixes issue #1371.
Any other comments?
Fixes a bug where C# Exceptions set as the Inner of another C# Exception, then converted into a Python exception object (and thus having
__cause__
set to a valid object) would leak theInner
/__cause__
objects.Simplified diagram :
In this case, where the AggregateException would be thrown from C# and caught in Python, the AggregateException and PyAggregateException would be freed, but not the ArgumentException set as the cause.
Checklist
Check all those that are applicable and complete.
AUTHORS
CHANGELOG