Segfault using Python ctypes module

Joshua Arnott josh@snorfalorpagus.net
Tue Nov 25 15:22:00 GMT 2014


Hello,

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
installer.

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,

Josh
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck.out
Type: application/octet-stream
Size: 167460 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20141125/e33e4e19/attachment.obj>
-------------- next part --------------
--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


More information about the Cygwin mailing list