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

Commitfd451d5

Browse files
committed
fixed Python derived types crashing on shutdown of Python process
clearing GCHandle from an instance of Python derived type would drop the last reference to it, so it was destroyed without being removed from reflectedObjects collection
1 parent943ff5e commitfd451d5

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

‎src/runtime/extensiontype.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,17 @@ public unsafe static void tp_dealloc(NewReference lastRef)
8080

8181
tp_clear(lastRef.Borrow());
8282

83-
booldeleted=loadedExtensions.Remove(lastRef.DangerousGetAddress());
84-
Debug.Assert(deleted);
85-
8683
// we must decref our type: https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_dealloc
8784
DecrefTypeAndFree(lastRef.Steal());
8885
}
8986

9087
publicstaticinttp_clear(BorrowedReferenceob)
9188
{
92-
TryFreeGCHandle(ob);
89+
if(TryFreeGCHandle(ob))
90+
{
91+
booldeleted=loadedExtensions.Remove(ob.DangerousGetAddress());
92+
Debug.Assert(deleted);
93+
}
9394

9495
intres=ClassBase.BaseUnmanagedClear(ob);
9596
returnres;

‎src/runtime/runtime.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ static bool TryCollectingGarbage(int runs, bool forceBreakLoops)
339339
elseif(forceBreakLoops)
340340
{
341341
NullGCHandles(CLRObject.reflectedObjects);
342+
CLRObject.reflectedObjects.Clear();
342343
}
343344
}
344345
returnfalse;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp