why does subtype_dict() and getset_get() makes infinite loop ?

umedoblock umedoblock at gmail.com
Fri Feb 10 17:06:22 EST 2012


Hi, everyone.
I'm umedoblock.

now, I wrote a below sentence.

But I cannot debug below infinite loop.
Do I mistake when I write a c exetension ?
I attached sample code.
Please help me.

==========================================
Python 3.2.2 (default, Jan 27 2012, 03:19:53)
[GCC 4.6.1] on linux2

class Bar_abstract(metaclass=ABCMeta):
    pass

# c extension
# class Bar_base(Bar_abstract):
#     pass

class Bar(Bar_base):
    pass
==========================================

but do this

bar = Bar()
dir(bar)

then python3.2.2 generates a core.
Because subtype_dict() and getset_get() makes infinite loop.

I checked stack with GDB.

==================================================================
#130948 0x0817670a in getset_get (descr=0xb73ae034, obj=0xb73e7e44,
    type=0x88ba4cc) at ../Objects/descrobject.c:148
#130949 0x080719f5 in subtype_dict (obj=0xb73e7e44, context=0x0)
    at ../Objects/typeobject.c:1756
#130950 0x0817670a in getset_get (descr=0xb73ae034, obj=0xb73e7e44,
    type=0x88ba4cc) at ../Objects/descrobject.c:148
#130951 0x080719f5 in subtype_dict (obj=0xb73e7e44, context=0x0)
    at ../Objects/typeobject.c:1756
#130952 0x0817670a in getset_get (descr=0xb73ae034, obj=0xb73e7e44,
    type=0x88ba4cc) at ../Objects/descrobject.c:148
#130953 0x080719f5 in subtype_dict (obj=0xb73e7e44, context=0x0)
    at ../Objects/typeobject.c:1756
==================================================================

GDB show me above code.
Now, I suspect below point PyObject_GetAttrString().

But I cannot debug this infinite loop.
Do I mistake when I write a c exetension ?
I attached sample code.
Please help me.

ojects/object.c:1325

static PyObject *
_generic_dir(PyObject *obj)
{
    PyObject *result = NULL;
    PyObject *dict = NULL;
    PyObject *itsclass = NULL;

    /* Get __dict__ (which may or may not be a real dict...) */
>>> dict = PyObject_GetAttrString(obj, "__dict__");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bar_ext.zip
Type: application/zip
Size: 3156 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20120211/5a8b0680/attachment.zip>


More information about the Python-list mailing list