[issue12881] ctypes: segfault with large structure field names

Meador Inge report at bugs.python.org
Wed Sep 14 04:42:59 CEST 2011


Meador Inge <meadori at gmail.com> added the comment:

> Note that there is at least one other place where alloca() is
> used with potentially large values:

Ouch!  I found three more crashers (including the one you found)
by grepping for 'alloca' in ctypes:

>>> from ctypes import *
>>> T = type('x' * 2 ** 25, (Structure,), {})
>>> p = POINTER(T)
Segmentation fault (core dumped)

>>> from ctypes import *
>>> p = POINTER('x' * 2 ** 25)
Segmentation fault (core dumped)

>>> from ctypes import *
>>> NARGS = 2 ** 20
>>> proto = CFUNCTYPE(None, *(c_int,) * NARGS)
>>> def func(*args):
...    return (1, "abc", None)
... 
>>> cb = proto(func)
>>> cb(*(1,) * NARGS)
Segmentation fault (core dumped)

I will fix those too.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12881>
_______________________________________


More information about the Python-bugs-list mailing list