diff options
author | Guido van Rossum <guido@python.org> | 2002-03-28 20:34:59 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2002-03-28 20:34:59 (GMT) |
commit | ff413af605d7aab610272c5668bc870ebcbf56ef (patch) | |
tree | 1a79acab5df1da3a36e5b78c093793f192b2c269 | |
parent | 31f8483eef19ebf40c7831d79cac270e69a96ce0 (diff) | |
download | cpython-ff413af605d7aab610272c5668bc870ebcbf56ef.zip cpython-ff413af605d7aab610272c5668bc870ebcbf56ef.tar.gz cpython-ff413af605d7aab610272c5668bc870ebcbf56ef.tar.bz2 |
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!
-rw-r--r-- | Modules/gcmodule.c | 4 | ||||
-rw-r--r-- | Objects/dictobject.c | 2 | ||||
-rw-r--r-- | Objects/frameobject.c | 2 | ||||
-rw-r--r-- | Objects/listobject.c | 2 | ||||
-rw-r--r-- | Objects/tupleobject.c | 2 |
5 files changed, 7 insertions, 5 deletions
diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index 71e9596..ed25bd4 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -819,7 +819,9 @@ _PyObject_GC_Track(PyObject *op) void _PyObject_GC_UnTrack(PyObject *op) { - _PyObject_GC_UNTRACK(op); + PyGC_Head *gc = AS_GC(op); + if (gc->gc.gc_next != NULL) + _PyObject_GC_UNTRACK(op); } PyObject * diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 5803c57..a83a851 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -694,8 +694,8 @@ dict_dealloc(register dictobject *mp) { register dictentry *ep; int fill = mp->ma_fill; + PyObject_GC_UnTrack(mp); Py_TRASHCAN_SAFE_BEGIN(mp) - _PyObject_GC_UNTRACK(mp); for (ep = mp->ma_table; fill > 0; ep++) { if (ep->me_key) { --fill; diff --git a/Objects/frameobject.c b/Objects/frameobject.c index cf3d73a..8e4c60f 100644 --- a/Objects/frameobject.c +++ b/Objects/frameobject.c @@ -67,8 +67,8 @@ frame_dealloc(PyFrameObject *f) PyObject **fastlocals; PyObject **p; + PyObject_GC_UnTrack(f); Py_TRASHCAN_SAFE_BEGIN(f) - _PyObject_GC_UNTRACK(f); /* Kill all local variables */ slots = f->f_nlocals + f->f_ncells + f->f_nfreevars; fastlocals = f->f_localsplus; diff --git a/Objects/listobject.c b/Objects/listobject.c index dbbc4a9..f3821f8 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -195,8 +195,8 @@ static void list_dealloc(PyListObject *op) { int i; + PyObject_GC_UnTrack(op); Py_TRASHCAN_SAFE_BEGIN(op) - _PyObject_GC_UNTRACK(op); if (op->ob_item != NULL) { /* Do it backwards, for Christian Tismer. There's a simple test case where somehow this reduces diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 27598ed..ab792de 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -139,8 +139,8 @@ tupledealloc(register PyTupleObject *op) { register int i; register int len = op->ob_size; + PyObject_GC_UnTrack(op); Py_TRASHCAN_SAFE_BEGIN(op) - _PyObject_GC_UNTRACK(op); if (len > 0) { i = len; while (--i >= 0) |