Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fixed crash in finalizer of CLR types defined in Python, that survive engine shutdown#1260

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
filmor merged 1 commit intopythonnet:masterfromlosttech:bugs/1256
Dec 18, 2020

Conversation

lostmsu
Copy link
Member

What does this implement/fix? Explain your changes.

During engine shutdown all links from Python to .NET instances are severed. If an instance of CLR class defined in Python survives the shutdown (for example, a reference is stored in static field) and later gets finalized, it will attempt to severe link again, which is an invalid operation.

The fix is to check if the link has already been severed and skip that step during finalization.

Additionally in this change: refactoredMoveClrInstancesOnwershipToPython

Does this close any currently open issues?

#1256

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 toAUTHORS
  • Updated theCHANGELOG

@lostmsulostmsuforce-pushed thebugs/1256 branch 4 times, most recently from9498c07 to927f980CompareOctober 13, 2020 17:26
@lostmsu
Copy link
MemberAuthor

lostmsu commentedOct 13, 2020
edited
Loading

Interesting. It appears, that the fix is legitimate, but the test for it causes segfault in soft shutdown mode with xplat. Which probably means it is caused by a separate issue :/

@codecov-io
Copy link

codecov-io commentedOct 13, 2020
edited
Loading

Codecov Report

Merging#1260 intomaster willnot change coverage.
The diff coverage isn/a.

Impacted file tree graph

@@           Coverage Diff           @@##           master    #1260   +/-   ##=======================================  Coverage   86.25%   86.25%           =======================================  Files           1        1             Lines         291      291           =======================================  Hits          251      251             Misses         40       40
FlagCoverage Δ
#setup_linux64.94% <ø> (ø)
#setup_windows72.50% <ø> (ø)

Flags with carried forward coverage won't be shown.Click here to find out more.


Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last updatef506d65...927f980. Read thecomment docs.

@lostmsu
Copy link
MemberAuthor

@amos402 I could see it being freed by one oftp_clear ortp_dealloc and then again by finalizer.

@amos402
Copy link
Member

GCHandlegc=GCHandle.Alloc(self,GCHandleType.Weak);
Marshal.WriteIntPtr(self.pyHandle,ObjectOffset.magic(self.tpHandle),(IntPtr)gc);
self.gcHandle.Free();
self.gcHandle=gc;

It set by a weak GCHandle instead after it freed.

@tminka
Copy link
Contributor

I have successfully avoided the problem mentioned by@amos402above via the followingcommit.

… engine shutdownpythonnet#1256pythonnet#1256During engine shutdown all links from Python to .NET instances are severed. If an instance of CLR class defined in Python survives the shutdown (for example, a reference is stored in static field) and later gets finalized, it will attempt to severe link again, which is an invalid operation.The fix is to check if the link has already been severed and skip that step during finalization.
@filmorfilmor merged commite2ab3ae intopythonnet:masterDec 18, 2020
BadSingleton pushed a commit to Unity-Technologies/pythonnet that referenced this pull requestDec 18, 2020
… engine shutdown (pythonnet#1260)pythonnet#1256pythonnet#1256During engine shutdown all links from Python to .NET instances are severed. If an instance of CLR class defined in Python survives the shutdown (for example, a reference is stored in static field) and later gets finalized, it will attempt to severe link again, which is an invalid operation.The fix is to check if the link has already been severed and skip that step during finalization.
BadSingleton pushed a commit to Unity-Technologies/pythonnet that referenced this pull requestDec 18, 2020
… engine shutdown (pythonnet#1260)pythonnet#1256pythonnet#1256During engine shutdown all links from Python to .NET instances are severed. If an instance of CLR class defined in Python survives the shutdown (for example, a reference is stored in static field) and later gets finalized, it will attempt to severe link again, which is an invalid operation.The fix is to check if the link has already been severed and skip that step during finalization.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@lostmsu@codecov-io@amos402@tminka@filmor

[8]ページ先頭

©2009-2025 Movatter.jp