Abort trap - Fatal Python error: GC object already tracked

p.lavarre at ieee.org p.lavarre at ieee.org
Tue Jul 10 13:53:00 EDT 2007


> Is this interesting Python output? ...
>
> Fatal Python error: GC object already tracked
> Abort trap
>
> ... tell me I can help by solving it, and
> I'll look more closely.

Sorry, never mind, not interesting after all.

Newbie me did somehow forget the fact that ctypes.memmove doesn't
bounds-check, e.g. there is no error raised by overwriting memory not
owned, which then naturally degrades the stability of the GC etc.

>>> import ctypes
>>>
>>> bytes = (3 * ctypes.c_ubyte)()
>>> bytes[0], bytes[1], bytes[2]
(0, 0, 0)
>>> CP = ctypes.POINTER
>>> ctypes.cast(ctypes.addressof(bytes) + 3, CP(ctypes.c_ubyte)).contents.value
0
>>>
>>> result = ctypes.memmove(ctypes.addressof(bytes), '\1\3\5\7', 4)
>>> bytes[0], bytes[1], bytes[2]
(1, 3, 5)
>>> ctypes.cast(ctypes.addressof(bytes) + 3, CP(ctypes.c_ubyte)).contents.value
7
>>>




More information about the Python-list mailing list