Skip to content

Commit 53e51a2

Browse files
committed
FIXME: Deactivate two clear cases for now to find the respective refcount issues
1 parent b98d641 commit 53e51a2

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

‎src/runtime/methodbinding.cs‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,9 @@ public MethodBinding(MethodObject m, IntPtr target, IntPtr targetType)
2525

2626
if (targetType == IntPtr.Zero)
2727
{
28-
targetType = Runtime.PyObject_Type(target);
29-
}
30-
else
31-
{
32-
Runtime.XIncref(targetType);
28+
targetType = Runtime.PyObject_TYPE(target);
3329
}
30+
Runtime.XIncref(targetType);
3431

3532
this.targetType = targetType;
3633

@@ -44,7 +41,7 @@ public MethodBinding(MethodObject m, IntPtr target) : this(m, target, IntPtr.Zer
4441

4542
private void ClearMembers()
4643
{
47-
Runtime.Py_CLEAR(ref target);
44+
// Runtime.Py_CLEAR(ref target);
4845
Runtime.Py_CLEAR(ref targetType);
4946
}
5047

@@ -248,6 +245,7 @@ public static IntPtr tp_repr(IntPtr ob)
248245
public static int tp_clear(IntPtr ob)
249246
{
250247
var self = (MethodBinding)GetManagedObject(ob);
248+
// Console.WriteLine($"{self.ToString()}, {self.target}, {self.targetType}, {self.m}, {self.m.name}");
251249
self?.ClearMembers();
252250
return 0;
253251
}

‎src/runtime/pythonexception.cs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public PythonException()
7777
}
7878
_finalized = true;
7979
Finalizer.Instance.AddFinalizedObject(ref _pyType);
80-
Finalizer.Instance.AddFinalizedObject(ref _pyValue);
80+
// Finalizer.Instance.AddFinalizedObject(ref _pyValue);
8181
Finalizer.Instance.AddFinalizedObject(ref _pyTB);
8282
}
8383

@@ -87,6 +87,9 @@ public PythonException()
8787
public void Restore()
8888
{
8989
IntPtr gs = PythonEngine.AcquireLock();
90+
Runtime.XIncref(_pyType);
91+
Runtime.XIncref(_pyValue);
92+
Runtime.XIncref(_pyTB);
9093
Runtime.PyErr_Restore(_pyType, _pyValue, _pyTB);
9194
_pyType = IntPtr.Zero;
9295
_pyValue = IntPtr.Zero;

0 commit comments

Comments
 (0)