Message94181
A segmentation fault is generated in _ctypes.so when calling a function that returns a char pointer on a system
with 64-bit pointer types. The attached crash dump is from a Python 2.6.3 built from MacPorts ("port install
python26 +no_tkinter"), but the same behaviour occurs with the Python 2.6.1 installed by Apple.
To reproduce, build the attached sample program ("testlib.c"):
% gcc -Wall -c testlib.o
% ld -dylib -o testlib.so testlib.o
Then, in Python:
# Common setup for each of the cases below.
>>> from ctypes import *
>>> lib = CDLL('testlib.so')
# Case 1: Integer return value (no crash).
>>> get_value = CFUNCTYPE(c_int)(lib.get_value)
>>> get_value()
12345
# Case 2: Pointer argument value (no crash).
>>> buf = create_string_buffer(256)
>>> copy_message = CFUNCTYPE(None, c_char_p)(lib.copy_message)
>>> copy_message(buf)
# Case 3: Pointer return value (crash).
>>> get_message = CFUNCTYPE(c_char_p)(lib.get_message)
>>> get_message()
Segmentation fault
-- System information:
% uname -a
MacOS 10.6.1
Darwin gorion.local 10.0.0 Darwin Kernel Version 10.0.0: Fri Jul 31 22:47:34 PDT 2009; root:xnu-
1456.1.25~1/RELEASE_I386 i386
% python
Python 2.6.3 (r263:75183, Oct 17 2009, 01:49:30)
[GCC 4.2.1 (Apple Inc. build 5646) (dot 1)] on darwin
% gcc --version
i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5646) (dot 1) |
|
Date |
User |
Action |
Args |
2009-10-17 16:31:05 | creachadair | set | recipients:
+ creachadair, theller |
2009-10-17 16:31:04 | creachadair | set | messageid: <1255797064.79.0.0899403156454.issue7160@psf.upfronthosting.co.za> |
2009-10-17 16:31:03 | creachadair | link | issue7160 messages |
2009-10-17 16:31:01 | creachadair | create | |
|