David Edelsohn <dje....@gmail.com> added the comment:

The bug report implies a different bug than what is being reported.  The bug is 
not related to calling a LIBC function with an argument list that does not 
match the function signature.

The true issue is that a Python ctypes structure definition on AIX that 
contains an array as in the example does not create an argument list that 
matches the AIX ABI for argument passing.  An example that directly uses libffi 
seems to work, but invoking libffi via Python ctypes does not.

In other words, Python ctypes structures created with _fields_ equivalent to

struct {
  const char *s;
  unsigned long d;
  size_t n;
}

should produce the same argument list as

struct {
  const char *s;
  unsigned long c_n[2];
}

but the version with the array does not.

libffi passes arrays as pointers, so Python ctypes converts arrays passed by 
value as libffi structs.  This occurs in cpython/Modules/_ctypes/stgdict.c .  
It is likely that ctypes is not generating the correct libffi descriptor.

The memchr example visually demonstrates the incorrect argument list, but is 
not intended to be correct, safe use of ctypes.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue38628>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to