On Fri, Oct 29, 2004 at 03:59:37PM -0400, Tim Peters wrote:
if clear_weakref doesn't know what the referent is, it can't find the pointer to the head of the referent's weakref list, so it can't unlink W from the list correctly (unlike gc's doubly-linked lists, weakref lists aren't circular, and don't have list heads) This leaves free'd memory *in* the referent's weakref list. So if the referent's refcount falls to 0 after that, then PyObject_ClearWeakRefs() goes nuts trying to crawl over the freed memory.
Crap. That's got to be the problem that I've been bashing my head against for the past few hours. Okay, how about we first clearly specify what needs to happen. Afterwards we can figure how to do it while retaining binary compatibility. :-( Non-trash weakrefs to trash objects MUST have their callbacks invoked. Trash weakrefs MUST NOT have their callbacks invoked. Any weakref to a trash object MUST NOT reveal the trash (i.e. via the wr_object pointer). Does that sound correct? Neil