[Python-Dev] Re: CVS Python is unstable

Guido van Rossum guido@digicool.com
Thu, 22 Mar 2001 23:34:48 -0500


Tim's problem can be reproduced in debug mode as follows (on Windows
as well as on Linux):

    import test.test_weakref
    import test.test_xmllib

Boom!  The debugger (on Windows) shows that it does in some GC code.

After backing out Fred's last change to _weakref.c, this works as
expected and I get no other problems.

So I propose to back out that change and be done with it.

Here's the CVS comment:

----------------------------
revision 1.8
date: 2001/03/22 18:05:30;  author: fdrake;  state: Exp;  lines: +1 -1

Inform the cycle-detector that the a weakref object no longer needs to be
tracked as soon as it is clear; this can decrease the number of roots for
the cycle detector sooner rather than later in applications which hold on
to weak references beyond the time of the invalidation.
----------------------------

And the diff, to be backed out:

*** _weakref.c	2001/02/27 18:36:56	1.7
--- _weakref.c	2001/03/22 18:05:30	1.8
***************
*** 59,64 ****
--- 59,65 ----
      if (self->wr_object != Py_None) {
          PyWeakReference **list = GET_WEAKREFS_LISTPTR(self->wr_object);
  
+         PyObject_GC_Fini((PyObject *)self);
          if (*list == self)
              *list = self->wr_next;
          self->wr_object = Py_None;
***************
*** 78,84 ****
  weakref_dealloc(PyWeakReference *self)
  {
      clear_weakref(self);
-     PyObject_GC_Fini((PyObject *)self);
      self->wr_next = free_list;
      free_list = self;
  }
--- 79,84 ----

Fred, can you explain what the intention of this code was?

It's not impossible that the bug is actually in the debug mode macros,
but I'd rather not ship code that's instable in debug mode -- that
defeats the purpose.

--Guido van Rossum (home page: http://www.python.org/~guido/)