Segfault using Python ctypes module

Joshua Arnott
Tue Nov 25 15:22:00 GMT 2014


I've come across an issue when using Python's ctypes module. On the
whole the module works correctly, but if an attempt is made to access
a property of the library that does not exist instead of raising the
appropriate exception a segmentation fault occurs. This is the case
for both Python 2.x and Python 3.x installed using the cygwin

See example blow. I've picked a random DLL for testing, as I don't
think it matters. The expected return from "hasattr(lib, 'fail')"
should be False. Instead a segmentation fault occurs. This problem
does not occur on the Windows version of Python that I also have
installed on the same machine, or on OS X.

$ python3
Python 3.2.5 (default, Jul 25 2014, 14:13:17)
[GCC 4.8.3] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ctypes
>>> lib = ctypes.CDLL('C:/Windows/System32/OpenCL.dll')
>>> lib
<CDLL 'C:/Windows/System32/OpenCL.dll', handle 7feea330000 at 6ffffe02b90>
>>> hasattr(lib, 'fail')
Segmentation fault (core dumped)

Kind regards,

-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck.out
Type: application/octet-stream
Size: 167460 bytes
Desc: not available
URL: <>
-------------- next part --------------
Problem reports:
Unsubscribe info:

More information about the Cygwin mailing list