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!
This commit is contained in:
parent
31f8483eef
commit
ff413af605
|
@ -819,7 +819,9 @@ _PyObject_GC_Track(PyObject *op)
|
||||||
void
|
void
|
||||||
_PyObject_GC_UnTrack(PyObject *op)
|
_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 *
|
PyObject *
|
||||||
|
|
|
@ -694,8 +694,8 @@ dict_dealloc(register dictobject *mp)
|
||||||
{
|
{
|
||||||
register dictentry *ep;
|
register dictentry *ep;
|
||||||
int fill = mp->ma_fill;
|
int fill = mp->ma_fill;
|
||||||
|
PyObject_GC_UnTrack(mp);
|
||||||
Py_TRASHCAN_SAFE_BEGIN(mp)
|
Py_TRASHCAN_SAFE_BEGIN(mp)
|
||||||
_PyObject_GC_UNTRACK(mp);
|
|
||||||
for (ep = mp->ma_table; fill > 0; ep++) {
|
for (ep = mp->ma_table; fill > 0; ep++) {
|
||||||
if (ep->me_key) {
|
if (ep->me_key) {
|
||||||
--fill;
|
--fill;
|
||||||
|
|
|
@ -67,8 +67,8 @@ frame_dealloc(PyFrameObject *f)
|
||||||
PyObject **fastlocals;
|
PyObject **fastlocals;
|
||||||
PyObject **p;
|
PyObject **p;
|
||||||
|
|
||||||
|
PyObject_GC_UnTrack(f);
|
||||||
Py_TRASHCAN_SAFE_BEGIN(f)
|
Py_TRASHCAN_SAFE_BEGIN(f)
|
||||||
_PyObject_GC_UNTRACK(f);
|
|
||||||
/* Kill all local variables */
|
/* Kill all local variables */
|
||||||
slots = f->f_nlocals + f->f_ncells + f->f_nfreevars;
|
slots = f->f_nlocals + f->f_ncells + f->f_nfreevars;
|
||||||
fastlocals = f->f_localsplus;
|
fastlocals = f->f_localsplus;
|
||||||
|
|
|
@ -195,8 +195,8 @@ static void
|
||||||
list_dealloc(PyListObject *op)
|
list_dealloc(PyListObject *op)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
PyObject_GC_UnTrack(op);
|
||||||
Py_TRASHCAN_SAFE_BEGIN(op)
|
Py_TRASHCAN_SAFE_BEGIN(op)
|
||||||
_PyObject_GC_UNTRACK(op);
|
|
||||||
if (op->ob_item != NULL) {
|
if (op->ob_item != NULL) {
|
||||||
/* Do it backwards, for Christian Tismer.
|
/* Do it backwards, for Christian Tismer.
|
||||||
There's a simple test case where somehow this reduces
|
There's a simple test case where somehow this reduces
|
||||||
|
|
|
@ -139,8 +139,8 @@ tupledealloc(register PyTupleObject *op)
|
||||||
{
|
{
|
||||||
register int i;
|
register int i;
|
||||||
register int len = op->ob_size;
|
register int len = op->ob_size;
|
||||||
|
PyObject_GC_UnTrack(op);
|
||||||
Py_TRASHCAN_SAFE_BEGIN(op)
|
Py_TRASHCAN_SAFE_BEGIN(op)
|
||||||
_PyObject_GC_UNTRACK(op);
|
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
i = len;
|
i = len;
|
||||||
while (--i >= 0)
|
while (--i >= 0)
|
||||||
|
|
Loading…
Reference in New Issue