Re: Pre-existing bug of the millennium (so far)

Tim Peters wrote: ...
Anyone have a bright idea? It's remarkable how long we've managed to go without noticing that everything is disastrously broken here <0.9 wink>.
Sure. Clearing cyclic trash can call Python code. If there are weakrefs to any of the cyclic trash, then those wekrefs can be used to resurrect the objects. Therefore, *before* clearing cyclic trash, we need to remove any weakrefs. If any of the weakrefs being removed have callbacks, then we need to save the callbacks and call them *after* all of the weakrefs have been cleared. Jim -- Jim Fulton mailto:jim@zope.com Python Powered! CTO (540) 361-1714 http://www.python.org Zope Corporation http://www.zope.com http://www.zope.org

[Tim]
...
Anyone have a bright idea? It's remarkable how long we've managed to go without noticing that everything is disastrously broken here <0.9 wink>.
[Jim]
Sure. Clearing cyclic trash can call Python code. If there are weakrefs to any of the cyclic trash, then those wekrefs can be used to resurrect the objects. Therefore, *before* clearing cyclic trash, we need to remove any weakrefs. If any of the weakrefs being removed have callbacks, then we need to save the callbacks and call them *after* all of the weakrefs have been cleared.
Thanks! Neil Schemenauer and I got together today, and talked each other into believing this can be made to work, and that it's likely the best solution too. The devil's in the details, but this a generalization of the last round of weakref vs. gc bugfixes, which got the effect of what you suggest here except only for cyclic-trash weakref objects with weakref callbacks. It needs generalization to all weakly-referenced cyclic-trash objects. Still unsure how hard that will be to code up, but am sure it will fix all the test cases I concocted.

It's not clear to me as to how severe a problem this is - given that beta2 is scheduled for next Wednesday, should I be delaying it? Anthony

[Anthony Baxter]
It's not clear to me as to how severe a problem this is -
It's a critical problem -- that's why I set the priority to 9. It affects all versions of Python since weakrefs were introduced. If you don't use weakrefs, or use any libraries that use weakrefs, it won't bite you. If you do, symptoms range from nothing, through "impossible AttributeError"s at seemingly random times, to segfaults.
given that beta2 is scheduled for next Wednesday, should I be delaying it?
I don't think so. On my home box, the Python test suite contains new tests for all the scenarios in the bug report, and I have a Python that passes the -uall test suite in debug and release builds. So it's looking good. I'm too punchy to check it in now, but if more tests pass I'll upload a patch to SF before I go to sleep, and assign it to Neil for review. The interactions between cyclic gc and weakrefs are arguably delicate <heh>.
participants (3)
-
Anthony Baxter
-
Jim Fulton
-
Tim Peters