Commit 9078b896 authored by Stefan Behnel's avatar Stefan Behnel

Rewrite tp_dealloc() of fused types functions to correctly disable GC before...

Rewrite tp_dealloc() of fused types functions to correctly disable GC before starting to clean up references.
parent 4326a3b9
...@@ -38,6 +38,9 @@ Bugs fixed ...@@ -38,6 +38,9 @@ Bugs fixed
* Annotations could be parsed (and rejected) as types even with * Annotations could be parsed (and rejected) as types even with
``annotation_typing=False``. ``annotation_typing=False``.
* Deallocating fused types functions and methods kept their GC tracking enabled,
which could lead to crashes.
0.27 (2017-09-23) 0.27 (2017-09-23)
================= =================
......
...@@ -505,15 +505,20 @@ __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m) ...@@ -505,15 +505,20 @@ __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
return 0; return 0;
} }
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m) static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
{ {
PyObject_GC_UnTrack(m);
if (__Pyx_CyFunction_weakreflist(m) != NULL) if (__Pyx_CyFunction_weakreflist(m) != NULL)
PyObject_ClearWeakRefs((PyObject *) m); PyObject_ClearWeakRefs((PyObject *) m);
__Pyx_CyFunction_clear(m); __Pyx_CyFunction_clear(m);
PyObject_GC_Del(m); PyObject_GC_Del(m);
} }
static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
{
PyObject_GC_UnTrack(m);
__Pyx__CyFunction_dealloc(m);
}
static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg) static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
{ {
Py_VISIT(m->func_closure); Py_VISIT(m->func_closure);
...@@ -830,9 +835,14 @@ __pyx_FusedFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, ...@@ -830,9 +835,14 @@ __pyx_FusedFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags,
return (PyObject *) fusedfunc; return (PyObject *) fusedfunc;
} }
static void __pyx_FusedFunction_dealloc(__pyx_FusedFunctionObject *self) { static void
__pyx_FusedFunction_clear(self); __pyx_FusedFunction_dealloc(__pyx_FusedFunctionObject *self)
__pyx_FusedFunctionType->tp_free((PyObject *) self); {
PyObject_GC_UnTrack(self);
Py_CLEAR(self->self);
Py_CLEAR(self->type);
Py_CLEAR(self->__signatures__);
__Pyx__CyFunction_dealloc((__pyx_CyFunctionObject *) self);
} }
static int static int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment