<br><div><span class="gmail_quote">On 4/15/06, <b class="gmail_sendername">Thomas Wouters</b> &lt;<a href="mailto:thomas@python.org">thomas@python.org</a>&gt; wrote:</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div style="direction: ltr;">(I first thought the problem was caused by gen_dealloc doing 'Py_DECREF(gen-&gt;gen_frame)' instead of 'frame = gen-&gt;gen_frame; gen-&gt;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.)
</div></blockquote><div><br> 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 :)
<br><br>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,
<br></div></div><br>Bad-pun'ly y'rs,<br>-- <br>Thomas Wouters &lt;<a href="mailto:thomas@python.org">thomas@python.org</a>&gt;<br><br>Hi! I'm a .signature virus! copy me into your .signature file to help me spread!