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 David.Edelsohn, pitrou
Date 2013-05-07.18:29:21
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1367951362.08.0.951682363124.issue17928@psf.upfronthosting.co.za>
In-reply-to
Content
Another endianness bug that causes a failure in test_structmembers.py.

_testcapi reports "string too long" because getargs.c:PyArg_ParseTupleAndKeywords() incorrectly returns a huge value for string_len.

The problem is FETCH_ARGS is passing the wrong type to va_arg.  It grabs an "int" for the size arg, but that is the not the argument type on 64 bit platforms.  This happens to work for little endian because the low part of the 64 bit argument overlaps correctly.  Big endian is not as fortuitous.

If I change "int" to "long", the testcase succeeds.

diff -r a285ce18bd55 Python/getargs.c
--- a/Python/getargs.c	Mon May 06 18:21:10 2013 -0700
+++ b/Python/getargs.c	Tue May 07 11:26:21 2013 -0700
@@ -582,9 +582,9 @@
               char *msgbuf, size_t bufsize, PyObject **freelist)
 {
     /* For # codes */
-#define FETCH_SIZE      int *q=NULL;Py_ssize_t *q2=NULL;\
+#define FETCH_SIZE      long *q=NULL;Py_ssize_t *q2=NULL;\
     if (flags & FLAG_SIZE_T) q2=va_arg(*p_va, Py_ssize_t*); \
-    else q=va_arg(*p_va, int*);
+    else q=va_arg(*p_va, long*);
 #define STORE_SIZE(s)   \
     if (flags & FLAG_SIZE_T) \
         *q2=s; \

I am not certain exactly what type it should be, but it definitely needs to be a matching 64 bit type of 64 bit platforms.

I believe that this bug exists in all versions.
History
Date User Action Args
2013-05-07 18:29:22David.Edelsohnsetrecipients: + David.Edelsohn, pitrou
2013-05-07 18:29:22David.Edelsohnsetmessageid: <1367951362.08.0.951682363124.issue17928@psf.upfronthosting.co.za>
2013-05-07 18:29:22David.Edelsohnlinkissue17928 messages
2013-05-07 18:29:21David.Edelsohncreate