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
This commit is contained in:
Родитель
e9c3a3d523
Коммит
2596cdf61c
|
@ -80,16 +80,17 @@ namespace Python.Runtime
|
|||
|
||||
tp_clear(lastRef.Borrow());
|
||||
|
||||
bool deleted = loadedExtensions.Remove(lastRef.DangerousGetAddress());
|
||||
Debug.Assert(deleted);
|
||||
|
||||
// we must decref our type: https://docs.python.org/3/c-api/typeobj.html#c.PyTypeObject.tp_dealloc
|
||||
DecrefTypeAndFree(lastRef.Steal());
|
||||
}
|
||||
|
||||
public static int tp_clear(BorrowedReference ob)
|
||||
{
|
||||
TryFreeGCHandle(ob);
|
||||
if (TryFreeGCHandle(ob))
|
||||
{
|
||||
bool deleted = loadedExtensions.Remove(ob.DangerousGetAddress());
|
||||
Debug.Assert(deleted);
|
||||
}
|
||||
|
||||
int res = ClassBase.BaseUnmanagedClear(ob);
|
||||
return res;
|
||||
|
|
|
@ -339,6 +339,7 @@ namespace Python.Runtime
|
|||
else if (forceBreakLoops)
|
||||
{
|
||||
NullGCHandles(CLRObject.reflectedObjects);
|
||||
CLRObject.reflectedObjects.Clear();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
Загрузка…
Ссылка в новой задаче