This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Trundle
Recipients Trundle, creachadair, theller
Date 2009-10-17.17:10:25
SpamBayes Score 3.4884845e-08
Marked as misclassified No
Message-id <1255799427.7.0.452876793669.issue7160@psf.upfronthosting.co.za>
In-reply-to
Content
You are using `CFUNCTYPE` wrong. `CFUNCTYPE` returns a type which will 
take a *Python function* (or an address of a function as integer). You 
provide `lib.get_message` as Python function, which is a wrapper object 
for the C function. By default, ctypes assumes an int as return type for 
C functions. On your platform, the size of an int is not the same as the 
size of a pointer. Therefore, the return value is truncated. You call 
the CFUNCTION which then calls `lib.get_message` which returns the 
truncated pointer as integer and then ctypes tries to make a `c_char_p` 
out of the integer which segfaults because it's truncated.

I think what you are really looking for is ``lib.get_message.restype = 
c_char_p``.
History
Date User Action Args
2009-10-17 17:10:27Trundlesetrecipients: + Trundle, theller, creachadair
2009-10-17 17:10:27Trundlesetmessageid: <1255799427.7.0.452876793669.issue7160@psf.upfronthosting.co.za>
2009-10-17 17:10:26Trundlelinkissue7160 messages
2009-10-17 17:10:25Trundlecreate