[New-bugs-announce] [issue16117] python2.7.3 struct misaligned when returned
Roland Lezuo
report at bugs.python.org
Wed Oct 3 11:30:39 CEST 2012
New submission from Roland Lezuo:
class Int(ctypes.Structure):
_fields_ = [ ("_i", ctypes.c_uint64),
("undef", ctypes.c_bool)]
class Int {
public:
Int();
Int(uint64_t i);
uint64_t _i;
bool undef;
};
extern "C" Int foo(const Int& a , const Int& b , const Int& c)
{
ret = ...
return Int(ret);
}
(gdb) p ret
$3 = 16
(gdb) fin
Run till exit from #0 BVSignExtend (a=..., b=..., c=...) at foo.hpp:130
0x00007ffff784eea4 in ffi_call_unix64 () from /usr/lib/python2.7/lib-dynload/_ctypes.so
Value returned is $4 = {_i = 18577824, undef = 16}
My guess: The value 18577824 was not expected to be on the stack.
The following actions "solve" the problem:
1) add another int the class Int (after bool) and adopt _fields_ accordingly.
2) in foo C++ function:
Int reti = Int(ret);
return reti;
Because of the "above" solutions I strongly suspect a bug in ctypes.
----------
components: ctypes
messages: 171876
nosy: iroli
priority: normal
severity: normal
status: open
title: python2.7.3 struct misaligned when returned
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue16117>
_______________________________________
More information about the New-bugs-announce
mailing list