Skip to content

Valid finalizer #532

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

Closed
wants to merge 17 commits into from
Closed

Conversation

dmitriyse
Copy link
Contributor

What does this implement/fix? Explain your changes.

Implements really working finalizers solution.
...

Does this close any currently open issues?

Probably some issues will be fixed.
...

Any other comments?

Current finalizers solution are totally not working. Probably interop calls are disallowed in the C# finalizers. Or Finalizer thread becomes broken after a few calls to ~PyObject.
...

Checklist

Check all those that are applicable and complete.

  • Make sure to include one or more tests for your change
  • If an enhancement PR, please create docs and at best an example
  • Add yourself to AUTHORS
  • Updated the CHANGELOG

@mention-bot
Copy link

@dmitriyse, thanks! @vmuriart, @tonyroberts, @hsoft, @cgohlke and @tiran, please review this.

@codecov
Copy link

codecov bot commented Aug 28, 2017

Codecov Report

Merging #532 into master will increase coverage by 0.03%.
The diff coverage is 72.22%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #532      +/-   ##
==========================================
+ Coverage   76.99%   77.03%   +0.03%     
==========================================
  Files          64       65       +1     
  Lines        5612     5747     +135     
  Branches      888      911      +23     
==========================================
+ Hits         4321     4427     +106     
- Misses       1002     1016      +14     
- Partials      289      304      +15
Flag Coverage Δ
#setup_linux 69.42% <ø> (ø) ⬆️
#setup_windows 76.23% <72.22%> (+0.05%) ⬆️
Impacted Files Coverage Δ
src/runtime/debughelper.cs 0% <ø> (ø) ⬆️
src/runtime/interop.cs 95.71% <ø> (-0.03%) ⬇️
src/runtime/runtime.cs 91.6% <100%> (+0.62%) ⬆️
src/runtime/classmanager.cs 94.9% <100%> (+0.06%) ⬆️
src/runtime/typemanager.cs 84.16% <100%> (+0.13%) ⬆️
src/runtime/classderived.cs 88.41% <100%> (+0.07%) ⬆️
src/runtime/methodbinding.cs 80% <100%> (ø) ⬆️
src/runtime/moduleobject.cs 85% <100%> (-0.06%) ⬇️
src/runtime/genericutil.cs 86.36% <100%> (+0.42%) ⬆️
src/runtime/assemblymanager.cs 89.83% <100%> (+0.05%) ⬆️
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c18285f...5ffab45. Read the comment docs.

@dmitriyse dmitriyse force-pushed the valid-finalizer branch 10 times, most recently from 0212233 to bfb6e59 Compare August 29, 2017 16:19
…oduces bugs when CPython freeing up enough objects.
@dmitriyse dmitriyse force-pushed the valid-finalizer branch 17 times, most recently from be8154f to 50fb157 Compare September 1, 2017 13:33
}
}
}
catch
Copy link
Contributor

Choose a reason for hiding this comment

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

isn't is better to explicitly fail, instead of "bypassing" the exception handling with an empty catch {}? What issue is this solving that disposed and disposing flags are not taking care of?


namespace Python.Runtime
{
internal class PyReferenceDecrementer : IDisposable
Copy link
Contributor

Choose a reason for hiding this comment

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

please explain (in the comments) the purpose of PyReferenceDecrementer and what issues it addressed?

////Marshal.FreeHGlobal(_programName);
////_programName = IntPtr.Zero;
////Marshal.FreeHGlobal(_pythonPath);
////_pythonPath = IntPtr.Zero;
Copy link
Contributor

Choose a reason for hiding this comment

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

💯 👍

@@ -568,15 +602,24 @@ internal GILState()
state = PythonEngine.AcquireLock();
}

protected virtual void Dispose(bool disposing)
{
//ReleeaseLock is thread bound and if it's called in finalizer thread it can wrongly release lock.
Copy link
Contributor

Choose a reason for hiding this comment

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

typo here

@den-run-ai
Copy link
Contributor

@dmitriyse @filmor i left some comments here, but I generally approve this pull request:

#532 (comment)
#532 (comment)
#532 (comment)

Copy link
Contributor

@den-run-ai den-run-ai left a comment

Choose a reason for hiding this comment

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

Please resolve merge conflicts

@dmitriyse dmitriyse mentioned this pull request Jun 24, 2018
4 tasks
@den-run-ai
Copy link
Contributor

@dmitriyse can you please resolve one merge conflict? can you remind me the order of PRs? If I don't get any feedback from @filmor @vmuriart @yagweb, then I'm going review again and merge this within 2 weeks, when I plan to be on vacation.

@den-run-ai den-run-ai requested a review from yagweb June 24, 2018 19:54
@den-run-ai
Copy link
Contributor

@dmitriyse ok, i found this message from you, please let me know if this is still valid:

#532 also depends on #534, (which is only a bunch of general fixes).
#532 is a superset of #534. So #534 just helps to separate general fixes from finalizer changes.
#531 does not depends on anything.

@dmitriyse
Copy link
Contributor Author

I will answer some day latter. Sorry.

@filmor filmor added this to the 2.4.0 milestone Aug 30, 2018
@filmor filmor mentioned this pull request Jan 18, 2019
@filmor filmor removed this from the 2.4.0 milestone Feb 5, 2019
@filmor filmor closed this Apr 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants