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 David.Edelsohn
Recipients Ayappan, David.Edelsohn, Michael.Felt
Date 2020-02-05.14:58:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1580914720.62.0.203336402105.issue38628@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-02-05 14:58:40David.Edelsohnsetrecipients: + David.Edelsohn, Michael.Felt, Ayappan
2020-02-05 14:58:40David.Edelsohnsetmessageid: <1580914720.62.0.203336402105.issue38628@roundup.psfhosted.org>
2020-02-05 14:58:40David.Edelsohnlinkissue38628 messages
2020-02-05 14:58:40David.Edelsohncreate