(original) (raw)
On 4/15/06, Thomas Wouters <thomas@python.org> wrote:
fixes the crash.Ah, found the problem. After I hit 'send', I realized I hadn't checked frameobject's tp\_clear, and sure enough, it calls Py\_XDECREF in-place. That explains why the first generator object gets dealloced twice, although it doesn't explain why it doesn't blow up when it reaches a negative refcount. Fixing frameobject and genobject to both use Py\_CLEAR() makes both the 'minimal' testcase and test\_generators work. Your testcase also stops leaking, but alas, test\_generators still leaks 255 references..... WTF-time for me, meaning I hit the sack and not think about it until next week :)
I'll upload a patch to Tim's bugreport after I remove my debugging cruft. All tp\_clear/tp\_traverse methods should really always use Py\_CLEAR/Py\_VISIT. I guess revisiting all tp\_clear and tp\_traverse methods is well worth putting on the TODO list,
(I first thought the problem was caused by gen\_dealloc doing 'Py\_DECREF(gen->gen\_frame)' instead of 'frame = gen->gen\_frame; gen->gen\_frame = NULL; Py\_DECREF(frame)', but that isn't the case. It should do it that way, I believe, but it's not the cause of this crash.)
fixes the crash.Ah, found the problem. After I hit 'send', I realized I hadn't checked frameobject's tp\_clear, and sure enough, it calls Py\_XDECREF in-place. That explains why the first generator object gets dealloced twice, although it doesn't explain why it doesn't blow up when it reaches a negative refcount. Fixing frameobject and genobject to both use Py\_CLEAR() makes both the 'minimal' testcase and test\_generators work. Your testcase also stops leaking, but alas, test\_generators still leaks 255 references..... WTF-time for me, meaning I hit the sack and not think about it until next week :)
I'll upload a patch to Tim's bugreport after I remove my debugging cruft. All tp\_clear/tp\_traverse methods should really always use Py\_CLEAR/Py\_VISIT. I guess revisiting all tp\_clear and tp\_traverse methods is well worth putting on the TODO list,
Bad-pun'ly y'rs,
--
Thomas Wouters <thomas@python.org>
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!