[Python-Dev] GC core dump caused by stringobject changes?
Andrew Kuchling
akuchlin@mems-exchange.org
Mon, 10 Jul 2000 22:34:04 -0400
On Mon, Jul 10, 2000 at 07:28:33PM -0600, Neil Schemenauer wrote:
>These seem to be the changes that trigger the bug. My problem or
>someone elses? No time to look in detail right now. :(
>+ seq = PySequence_Fast(orig, "");
...
>+ item = PySequence_Fast_GET_ITEM(seq, i);
...
>+ Py_DECREF(item);
I think item shouldn't be DECREF'ed at all. Looking at what
PySequence_Fast does, it either INCREF's its argument if it's a list
or tuple and returns it, or coerces it to a tuple. It doesn't look
like PySequence_Fast increments the refcount of what it returns.
seq does need to be DECREF'ed, though:
>>> import sys
>>> L=['a', 'b', 'c']
>>> sys.getrefcount(L)
2
>>> for i in range(1000): a = ' '.join(L)
...
>>> sys.getrefcount(L)
1002
>>>
--amk