[Python-Dev] Debugging opportunity :-)

Thomas Wouters thomas at python.org
Sat Apr 15 01:11:42 CEST 2006


On 4/15/06, Thomas Wouters <thomas at python.org> wrote:

> (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 at python.org>

Hi! I'm a .signature virus! copy me into your .signature file to help me
spread!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20060415/f8c5ecf0/attachment.html 


More information about the Python-Dev mailing list