Issue 1000914: Carbon.CF.CFMutableArray hangs interpreter (original) (raw)
$ /opt/python2.4/bin/python Python 2.4a1+ (#1, Jul 30 2004, 20:22:17) [GCC 3.3 20030304 (Apple Computer, Inc. build 1495)] on darwin Type "help", "copyright", "credits" or "license" for more information.
from Carbon.CF import * c = CFArrayCreateMutable(0) isinstance(c, CFMutableArrayRef) True del c
The interpreter hangs after deleting c. This also happens when the call to isinstance is left out.
Logged In: YES user_id=580910
when I use gdb to check where the program hangs I always end up in CFArrayRefObj_dealloc. This also happens when I continue to program and break again later on.
It doesn't seem to be infinite recursion, the stack is 8 levels deep with the code mentioned earlier.
However: (gdb) where #0 0x00551f98 in CFArrayRefObj_dealloc (self=0x37f0e0) at /Volumes/ Data/Users/ronald/Software/python-HEAD/dist/src/Mac/Modules/cf/ _CFmodule.c:525 #1 0x0008879c in PyEval_EvalFrame (f=0x60d820) at Python/ceval.c: 1662 #2 0x0008a4bc in PyEval_EvalCodeEx (co=0x2, globals=0x59e54, locals=0x552308, args=0x16c, argcount=6312944, kws=0x874a0, kwcount=1, defs=0x60d96c, defcount=0, closure=0x0) at Python/ ceval.c:2697 #3 0x0008d648 in PyEval_EvalCode (co=0x37f0e0, globals=0x59e54, locals=0x55e1d4) at Python/ceval.c:448 #4 0x0000c9a0 in run_node (n=0x16c, filename=0x59e54 "\201^", globals=0x2, locals=0x60d96c, flags=0x0) at Python/pythonrun.c:1255 #5 0x0000c128 in PyRun_SimpleFileExFlags (fp=0xa0009818, filename=0xbffffc9e "t.py", closeit=6346784, flags=0x377a92) at Python/ pythonrun.c:850 #6 0x00006328 in Py_Main (argc=3533392, argv=0xbffffc9e) at Modules/main.c:413 #7 0x00001ee4 in _start (argc=3533392, argv=0xa0009818, envp=0xbffffc9e) at /SourceCache/Csu/Csu-46/crt.c:267 #8 0x00001d58 in start () (gdb) p self $3 = (CFArrayRefObject *) 0x37f0e0 (gdb) p *self $4 = { ob_refcnt = 0, ob_type = 0x55e2e4, ob_itself = 0x0, ob_freeit = 0x90190b98 } (gdb) p self->ob_type->tp_base $5 = (struct _typeobject *) 0x55e1d4 (gdb) p self->ob_type->tp_base->tp_dealloc $6 = 0x551f48 (gdb)
And CFArrayRefObj_dealloc is:
static void CFArrayRefObj_dealloc(CFArrayRefObject *self) { if (self->ob_freeit && self->ob_itself) { self->ob_freeit((CFTypeRef)self->ob_itself); self->ob_itself = NULL; } self->ob_type->tp_base->tp_dealloc((PyObject *)self); }
BTW: Python 2.4a1+ from anon-CVS as of today, running on OSX 10.3.4 with Xcode 1.2 (gcc 3.3)
Logged In: YES user_id=580910
It's infinite recursion...
- CF.CFMutableArrayRef has is a subtype of CF.CFArrayRef
- Both tp_del's call 'self->ob_type->tp_base->tp_dealloc' to deallocate the instance.
- When the instance is an CFMutableArrayRef self->ob_type->tp_base is CFArrayRef, which means we get:
- Object refcount is 0, call tp_dealloc
- Enter CFMutableArrayRefObj_dealloc
- Call self->ob_type->tp_dealloc
- Enter CFArrayRefObj_dealloc
- Call self->ob_type->tp_dealloc
- Enter CFArrayRefObj_dealloc
- ...
I guess the right change is in Tools/bgen/bgen/bgenObjectDefinition.py: outputDealloc.
Near line 138 this prints the problematic 'self->ob_type->tp_base-
tp_dealloc'. I'd change this to:
Output("%s.tp_dealloc((PyObject*)self);"%(self.basetype,))