[issue21983] segfault in ctypes.cast
Anthony LaTorre
report at bugs.python.org
Mon Jul 14 23:53:26 CEST 2014
New submission from Anthony LaTorre:
I get a segfault when trying to cast a string to a structure.
>>> import ctypes
>>> class Struct(ctypes.Structure):
... _fields_ = [('a', ctypes.c_uint32)]
...
>>> s = '0'*100
>>> ctypes.cast(s,Struct)
Segmentation fault
The docs (https://docs.python.org/2/library/ctypes.html#ctypes.cast) say that `obj` "must be an object that can be interpreted as a pointer", so I assume this should return the same exception you get when trying to cast a list:
>>> ctypes.cast(range(10),Struct)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/ctypes/__init__.py", line 488, in cast
return _cast(obj, obj, typ)
ctypes.ArgumentError: argument 1: <class 'TypeError'>: wrong type
----------
messages: 223062
nosy: Anthony.LaTorre
priority: normal
severity: normal
status: open
title: segfault in ctypes.cast
type: crash
versions: Python 2.7, Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21983>
_______________________________________
More information about the Python-bugs-list
mailing list