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

Commit1fd6dc2

Browse files
committed
fixed crash in finalizer of CLR types defined in Python, that survive engine shutdown
#1256#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.
1 parent44a36dc commit1fd6dc2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎src/runtime/classderived.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ public static void Finalize(IPythonDerivedType obj)
857857
{
858858
if(0==Runtime.Py_IsInitialized()||Runtime.IsFinalizing)
859859
{
860-
self.gcHandle.Free();
860+
if(self.gcHandle.IsAllocated)self.gcHandle.Free();
861861
return;
862862
}
863863
}
@@ -872,7 +872,7 @@ public static void Finalize(IPythonDerivedType obj)
872872
// If python's been terminated then just free the gchandle.
873873
if(0==Runtime.Py_IsInitialized()||Runtime.IsFinalizing)
874874
{
875-
self.gcHandle.Free();
875+
if(self.gcHandle.IsAllocated)self.gcHandle.Free();
876876
return;
877877
}
878878

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp