]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Sort-of backport to 2.1.3 (if we ever release it) of the following.
authorGuido van Rossum <guido@python.org>
Thu, 28 Mar 2002 20:41:02 +0000 (20:41 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 28 Mar 2002 20:41:02 +0000 (20:41 +0000)
(The fix looks different, but does the same thing to the 2.1 GC code
that Neil's patch does to the 2.2 GC code.)

This is Neil's fix for SF bug 535905 (Evil Trashcan and GC interaction).

The fix makes it possible to call PyObject_GC_UnTrack() more than once
on the same object, and then move the PyObject_GC_UnTrack() call to
*before* the trashcan code is invoked.

BUGFIX CANDIDATE!

Modules/gcmodule.c
Objects/dictobject.c
Objects/listobject.c
Objects/tupleobject.c

index e781bdf9e7869d90b0225f7a727756fba0db0143..011bb1461a9cd9e6f82b1fd08c198a3270314195 100644 (file)
@@ -87,12 +87,14 @@ gc_list_append(PyGC_Head *node, PyGC_Head *list)
 static void
 gc_list_remove(PyGC_Head *node)
 {
+       if (node->gc_next == NULL)
+               return;
        node->gc_prev->gc_next = node->gc_next;
        node->gc_next->gc_prev = node->gc_prev;
 #ifdef Py_DEBUG
        node->gc_prev = NULL;
-       node->gc_next = NULL;
 #endif
+       node->gc_next = NULL;
 }
 
 static void 
index 8ad44c181cd16d5da7e75d7ae44fdb1d66ee72d7..bac0edfc2de07d0ecaf82f7031a29cf01b524488 100644 (file)
@@ -619,8 +619,8 @@ dict_dealloc(register dictobject *mp)
 {
        register int i;
        register dictentry *ep;
-       Py_TRASHCAN_SAFE_BEGIN(mp)
        PyObject_GC_Fini(mp);
+       Py_TRASHCAN_SAFE_BEGIN(mp)
        for (i = 0, ep = mp->ma_table; i < mp->ma_size; i++, ep++) {
                if (ep->me_key != NULL) {
                        Py_DECREF(ep->me_key);
index 7044edeea4f6b79744cd8a6f59b27de44414ffce..6868504ab32389de2d58f26bbbf9ab365866e641 100644 (file)
@@ -176,8 +176,8 @@ static void
 list_dealloc(PyListObject *op)
 {
        int i;
-       Py_TRASHCAN_SAFE_BEGIN(op)
        PyObject_GC_Fini(op);
+       Py_TRASHCAN_SAFE_BEGIN(op)
        if (op->ob_item != NULL) {
                /* Do it backwards, for Christian Tismer.
                   There's a simple test case where somehow this reduces
index ca76bb5923ff88549af37ed25ffc9b8ba614ef4e..000856d5f6f5f3b14ae48f54985ac7f61bcc7f5d 100644 (file)
@@ -143,8 +143,8 @@ tupledealloc(register PyTupleObject *op)
 {
        register int i;
        register int len =  op->ob_size;
-       Py_TRASHCAN_SAFE_BEGIN(op)
        PyObject_GC_Fini(op);
+       Py_TRASHCAN_SAFE_BEGIN(op)
        if (len > 0) {
                i = len;
                while (--i >= 0)